mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-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 vim/vim#4805, closes vim/vim#4843, closes vim/vim#4939, closes vim/vim#4844)
6f10c70b59
This commit is contained in:
parent
64a2884d4c
commit
310a56d0a0
@ -186,14 +186,17 @@ int open_buffer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// If there is no memfile at all, exit.
|
||||||
* if there is no memfile at all, exit
|
// This is OK, since there are no changes to lose.
|
||||||
* This is OK, since there are no changes to lose.
|
|
||||||
*/
|
|
||||||
if (curbuf == NULL) {
|
if (curbuf == NULL) {
|
||||||
EMSG(_("E82: Cannot allocate any buffer, exiting..."));
|
EMSG(_("E82: Cannot allocate any buffer, exiting..."));
|
||||||
|
|
||||||
|
// Don't try to do any saving, with "curbuf" NULL almost nothing
|
||||||
|
// will work.
|
||||||
|
v_dying = 2;
|
||||||
getout(2);
|
getout(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
EMSG(_("E83: Cannot allocate buffer, using other one..."));
|
EMSG(_("E83: Cannot allocate buffer, using other one..."));
|
||||||
enter_buffer(curbuf);
|
enter_buffer(curbuf);
|
||||||
if (old_tw != curbuf->b_p_tw) {
|
if (old_tw != curbuf->b_p_tw) {
|
||||||
|
@ -7444,6 +7444,8 @@ static int syn_add_group(char_u *name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char_u *const name_up = vim_strsave_up(name);
|
||||||
|
|
||||||
// Append another syntax_highlight entry.
|
// Append another syntax_highlight entry.
|
||||||
struct hl_group* hlgp = GA_APPEND_VIA_PTR(struct hl_group, &highlight_ga);
|
struct hl_group* hlgp = GA_APPEND_VIA_PTR(struct hl_group, &highlight_ga);
|
||||||
memset(hlgp, 0, sizeof(*hlgp));
|
memset(hlgp, 0, sizeof(*hlgp));
|
||||||
@ -7452,7 +7454,7 @@ static int syn_add_group(char_u *name)
|
|||||||
hlgp->sg_rgb_fg = -1;
|
hlgp->sg_rgb_fg = -1;
|
||||||
hlgp->sg_rgb_sp = -1;
|
hlgp->sg_rgb_sp = -1;
|
||||||
hlgp->sg_blend = -1;
|
hlgp->sg_blend = -1;
|
||||||
hlgp->sg_name_u = vim_strsave_up(name);
|
hlgp->sg_name_u = name_up;
|
||||||
|
|
||||||
return highlight_ga.ga_len; /* ID is index plus one */
|
return highlight_ga.ga_len; /* ID is index plus one */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user