Skip to content

Commit dc75a20

Browse files
brandb97chrisbra
authored andcommitted
patch 9.1.1851: memory leak in heredoc_get()
Problem: memory leak in heredoc_get() Solution: Free "str" if list_append_string() fails (Lidong Yan). In heredoc_get(), eval_all_expr_in_str() allocates a new string and assign it to local variable "str". When list_append_string() failed the memory pointed to by "str" leaks. Free "str" if list_append_string() failed. related: #18533 Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent da2dabc commit dc75a20

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/evalvars.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,11 @@ heredoc_get(exarg_T *eap, char_u *cmd, int script_get, int vim9compile)
968968
}
969969

970970
if (list_append_string(l, str, -1) == FAIL)
971+
{
972+
if (free_str)
973+
vim_free(str);
971974
break;
975+
}
972976
if (free_str)
973977
vim_free(str);
974978
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ static char *(features[]) =
729729

730730
static int included_patches[] =
731731
{ /* Add new patch number below this line */
732+
/**/
733+
1851,
732734
/**/
733735
1850,
734736
/**/

0 commit comments

Comments
 (0)