Mercurial > vim
comparison src/main.c @ 18045:af0b4ffab794 v8.1.2018
patch 8.1.2018: using freed memory when out of memory and displaying message
Commit: https://github.com/vim/vim/commit/e5fbd7393067c279860598ac8359d1617b1082b9
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 9 20:04:13 2019 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 09 Sep 2019 20:15:03 +0200 |
parents | b27d06bd0fde |
children | 1101eacc1444 |
comparison
equal
deleted
inserted
replaced
18044:062623edb7c8 | 18045:af0b4ffab794 |
---|---|
1274 curbuf->b_last_used = vim_time(); | 1274 curbuf->b_last_used = vim_time(); |
1275 #endif | 1275 #endif |
1276 /* display message after redraw */ | 1276 /* display message after redraw */ |
1277 if (keep_msg != NULL) | 1277 if (keep_msg != NULL) |
1278 { | 1278 { |
1279 char_u *p; | 1279 char_u *p = vim_strsave(keep_msg); |
1280 | 1280 |
1281 // msg_attr_keep() will set keep_msg to NULL, must free the | 1281 if (p != NULL) |
1282 // string here. Don't reset keep_msg, msg_attr_keep() uses it | 1282 { |
1283 // to check for duplicates. Never put this message in history. | 1283 // msg_start() will set keep_msg to NULL, make a copy |
1284 p = keep_msg; | 1284 // first. Don't reset keep_msg, msg_attr_keep() uses it to |
1285 msg_hist_off = TRUE; | 1285 // check for duplicates. Never put this message in |
1286 msg_attr((char *)p, keep_msg_attr); | 1286 // history. |
1287 msg_hist_off = FALSE; | 1287 msg_hist_off = TRUE; |
1288 vim_free(p); | 1288 msg_attr((char *)p, keep_msg_attr); |
1289 msg_hist_off = FALSE; | |
1290 vim_free(p); | |
1291 } | |
1289 } | 1292 } |
1290 if (need_fileinfo) /* show file info after redraw */ | 1293 if (need_fileinfo) /* show file info after redraw */ |
1291 { | 1294 { |
1292 fileinfo(FALSE, TRUE, FALSE); | 1295 fileinfo(FALSE, TRUE, FALSE); |
1293 need_fileinfo = FALSE; | 1296 need_fileinfo = FALSE; |