summaryrefslogtreecommitdiff
path: root/src/normal.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-09 20:04:13 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-09 20:04:13 +0200
commite5fbd7393067c279860598ac8359d1617b1082b9 (patch)
tree2b7d0d632f24b3659717bccf8c4d9e70f2c1f95b /src/normal.c
parent96e38a86a710fb6daec4550ac1667f019dc3a40e (diff)
downloadvim-git-e5fbd7393067c279860598ac8359d1617b1082b9.tar.gz
patch 8.1.2018: using freed memory when out of memory and displaying messagev8.1.2018
Problem: Using freed memory when out of memory and displaying message. Solution: Make a copy of the message first.
Diffstat (limited to 'src/normal.c')
-rw-r--r--src/normal.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/normal.c b/src/normal.c
index 7abd3fc99..d169f260a 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -1182,12 +1182,17 @@ getcount:
kmsg = keep_msg;
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);
- /* 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;
- msg_attr((char *)kmsg, keep_msg_attr);
- vim_free(kmsg);
+
+ kmsg = vim_strsave(keep_msg);
+ if (kmsg != NULL)
+ {
+ msg_attr((char *)kmsg, keep_msg_attr);
+ vim_free(kmsg);
+ }
}
setcursor();
cursor_on();