0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -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:
Bram Moolenaar
2019-09-09 20:04:13 +02:00
parent 96e38a86a7
commit e5fbd73930
4 changed files with 23 additions and 18 deletions

View File

@@ -1276,16 +1276,19 @@ main_loop(
/* display message after redraw */
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
// string here. Don't reset keep_msg, msg_attr_keep() uses it
// to check for duplicates. Never put this message in history.
p = keep_msg;
msg_hist_off = TRUE;
msg_attr((char *)p, keep_msg_attr);
msg_hist_off = FALSE;
vim_free(p);
if (p != NULL)
{
// msg_start() will set keep_msg to NULL, make a copy
// 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_attr((char *)p, keep_msg_attr);
msg_hist_off = FALSE;
vim_free(p);
}
}
if (need_fileinfo) /* show file info after redraw */
{