Mercurial > vim
diff src/normal.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 | 2ea47dee7ddd |
children | 90b0af9ba4ff |
line wrap: on
line diff
--- 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();