mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.1.2018: using freed memory when out of memory and displaying message
Problem: Using freed memory when out of memory and displaying message. Solution: Make a copy of the message first.
This commit is contained in:
parent
96e38a86a7
commit
e5fbd73930
13
src/main.c
13
src/main.c
@ -1276,17 +1276,20 @@ main_loop(
|
|||||||
/* display message after redraw */
|
/* display message after redraw */
|
||||||
if (keep_msg != NULL)
|
if (keep_msg != NULL)
|
||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p = vim_strsave(keep_msg);
|
||||||
|
|
||||||
// msg_attr_keep() will set keep_msg to NULL, must free the
|
if (p != NULL)
|
||||||
// string here. Don't reset keep_msg, msg_attr_keep() uses it
|
{
|
||||||
// to check for duplicates. Never put this message in history.
|
// msg_start() will set keep_msg to NULL, make a copy
|
||||||
p = keep_msg;
|
// first. Don't reset keep_msg, msg_attr_keep() uses it to
|
||||||
|
// check for duplicates. Never put this message in
|
||||||
|
// history.
|
||||||
msg_hist_off = TRUE;
|
msg_hist_off = TRUE;
|
||||||
msg_attr((char *)p, keep_msg_attr);
|
msg_attr((char *)p, keep_msg_attr);
|
||||||
msg_hist_off = FALSE;
|
msg_hist_off = FALSE;
|
||||||
vim_free(p);
|
vim_free(p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (need_fileinfo) /* show file info after redraw */
|
if (need_fileinfo) /* show file info after redraw */
|
||||||
{
|
{
|
||||||
fileinfo(FALSE, TRUE, FALSE);
|
fileinfo(FALSE, TRUE, FALSE);
|
||||||
|
@ -168,11 +168,6 @@ msg_attr_keep(
|
|||||||
ch_log(NULL, "ERROR: %s", (char *)s);
|
ch_log(NULL, "ERROR: %s", (char *)s);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* When displaying keep_msg, don't let msg_start() free it, caller must do
|
|
||||||
* that. */
|
|
||||||
if ((char_u *)s == keep_msg)
|
|
||||||
keep_msg = NULL;
|
|
||||||
|
|
||||||
/* Truncate the message if needed. */
|
/* Truncate the message if needed. */
|
||||||
msg_start();
|
msg_start();
|
||||||
buf = msg_strtrunc((char_u *)s, FALSE);
|
buf = msg_strtrunc((char_u *)s, FALSE);
|
||||||
|
@ -1182,13 +1182,18 @@ getcount:
|
|||||||
|
|
||||||
kmsg = keep_msg;
|
kmsg = keep_msg;
|
||||||
keep_msg = NULL;
|
keep_msg = NULL;
|
||||||
/* showmode() will clear keep_msg, but we want to use it anyway */
|
// showmode() will clear keep_msg, but we want to use it anyway
|
||||||
update_screen(0);
|
update_screen(0);
|
||||||
/* now reset it, otherwise it's put in the history again */
|
// now reset it, otherwise it's put in the history again
|
||||||
keep_msg = kmsg;
|
keep_msg = kmsg;
|
||||||
|
|
||||||
|
kmsg = vim_strsave(keep_msg);
|
||||||
|
if (kmsg != NULL)
|
||||||
|
{
|
||||||
msg_attr((char *)kmsg, keep_msg_attr);
|
msg_attr((char *)kmsg, keep_msg_attr);
|
||||||
vim_free(kmsg);
|
vim_free(kmsg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
setcursor();
|
setcursor();
|
||||||
cursor_on();
|
cursor_on();
|
||||||
out_flush();
|
out_flush();
|
||||||
|
@ -757,6 +757,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2018,
|
||||||
/**/
|
/**/
|
||||||
2017,
|
2017,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user