]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1851: memory leak in heredoc_get() v9.1.1851
authorLidong Yan <502024330056@smail.nju.edu.cn>
Sun, 12 Oct 2025 15:05:11 +0000 (15:05 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 12 Oct 2025 15:05:11 +0000 (15:05 +0000)
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>
src/evalvars.c
src/version.c

index e529758ef32107e75301838b477e527f79387af3..c840d872bd04f32ca6a5b47712e4d690761acd1f 100644 (file)
@@ -968,7 +968,11 @@ heredoc_get(exarg_T *eap, char_u *cmd, int script_get, int vim9compile)
            }
 
            if (list_append_string(l, str, -1) == FAIL)
+           {
+               if (free_str)
+                   vim_free(str);
                break;
+           }
            if (free_str)
                vim_free(str);
        }
index 3f6baf6bb22cb67fda6db2aac9ff2f822b985b9a..d46906ab276c0924cca8273660c19bc04931271c 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1851,
 /**/
     1850,
 /**/