summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-11-25 14:43:18 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-25 14:43:18 +0000
commitba8c92687d53c91bbc20c867a49e0988819ea2d5 (patch)
treedb3b62668431734ada77a7b187904dd112b69450 /src
parent96e7a5928e1e7a350cd6c6d0b9376305190046e7 (diff)
patch 8.2.3675: using freed memory when vim_strsave() failsv8.2.3675
Problem: Using freed memory when vim_strsave() fails. Solution: Clear "last_sourcing_name". Check for msg_source() called recursively. (closes #8217)
Diffstat (limited to 'src')
-rw-r--r--src/message.c14
-rw-r--r--src/version.c2
2 files changed, 12 insertions, 4 deletions
diff --git a/src/message.c b/src/message.c
index e438211fa1..8992de013f 100644
--- a/src/message.c
+++ b/src/message.c
@@ -522,6 +522,12 @@ get_emsg_lnum(void)
msg_source(int attr)
{
char_u *p;
+ static int recursive = FALSE;
+
+ // Bail out if something called here causes an error.
+ if (recursive)
+ return;
+ recursive = TRUE;
++no_wait_return;
p = get_emsg_source();
@@ -541,13 +547,13 @@ msg_source(int attr)
// remember the last sourcing name printed, also when it's empty
if (SOURCING_NAME == NULL || other_sourcing_name())
{
- vim_free(last_sourcing_name);
- if (SOURCING_NAME == NULL)
- last_sourcing_name = NULL;
- else
+ VIM_CLEAR(last_sourcing_name);
+ if (SOURCING_NAME != NULL)
last_sourcing_name = vim_strsave(SOURCING_NAME);
}
--no_wait_return;
+
+ recursive = FALSE;
}
/*
diff --git a/src/version.c b/src/version.c
index 6d96d43247..07d93d98b7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3675,
+/**/
3674,
/**/
3673,