Mercurial > vim
comparison src/highlight.c @ 17797:ec1717981acf v8.1.1895
patch 8.1.1895: using NULL pointer when out of memory
commit https://github.com/vim/vim/commit/6f10c70b59fa4e56aa479345fb0caeaac7429bfb
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 20 22:58:37 2019 +0200
patch 8.1.1895: using NULL pointer when out of memory
Problem: Using NULL pointer when out of memory.
Solution: Bail out or skip the code using the pointer. (Zu-Ming Jiang,
closes #4805, closes #4843, closes #4939, closes #4844)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 20 Aug 2019 23:00:04 +0200 |
parents | 04245f071792 |
children | 59f8948b7590 |
comparison
equal
deleted
inserted
replaced
17796:9ebba5c49827 | 17797:ec1717981acf |
---|---|
3014 */ | 3014 */ |
3015 static int | 3015 static int |
3016 syn_add_group(char_u *name) | 3016 syn_add_group(char_u *name) |
3017 { | 3017 { |
3018 char_u *p; | 3018 char_u *p; |
3019 char_u *name_up; | |
3019 | 3020 |
3020 // Check that the name is ASCII letters, digits and underscore. | 3021 // Check that the name is ASCII letters, digits and underscore. |
3021 for (p = name; *p != NUL; ++p) | 3022 for (p = name; *p != NUL; ++p) |
3022 { | 3023 { |
3023 if (!vim_isprintc(*p)) | 3024 if (!vim_isprintc(*p)) |
3059 { | 3060 { |
3060 vim_free(name); | 3061 vim_free(name); |
3061 return 0; | 3062 return 0; |
3062 } | 3063 } |
3063 | 3064 |
3065 name_up = vim_strsave_up(name); | |
3066 if (name_up == NULL) | |
3067 { | |
3068 vim_free(name); | |
3069 return 0; | |
3070 } | |
3071 | |
3064 vim_memset(&(HL_TABLE()[highlight_ga.ga_len]), 0, sizeof(hl_group_T)); | 3072 vim_memset(&(HL_TABLE()[highlight_ga.ga_len]), 0, sizeof(hl_group_T)); |
3065 HL_TABLE()[highlight_ga.ga_len].sg_name = name; | 3073 HL_TABLE()[highlight_ga.ga_len].sg_name = name; |
3066 HL_TABLE()[highlight_ga.ga_len].sg_name_u = vim_strsave_up(name); | 3074 HL_TABLE()[highlight_ga.ga_len].sg_name_u = name_up; |
3067 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | 3075 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
3068 HL_TABLE()[highlight_ga.ga_len].sg_gui_bg = INVALCOLOR; | 3076 HL_TABLE()[highlight_ga.ga_len].sg_gui_bg = INVALCOLOR; |
3069 HL_TABLE()[highlight_ga.ga_len].sg_gui_fg = INVALCOLOR; | 3077 HL_TABLE()[highlight_ga.ga_len].sg_gui_fg = INVALCOLOR; |
3070 # ifdef FEAT_GUI | 3078 # ifdef FEAT_GUI |
3071 HL_TABLE()[highlight_ga.ga_len].sg_gui_sp = INVALCOLOR; | 3079 HL_TABLE()[highlight_ga.ga_len].sg_gui_sp = INVALCOLOR; |