patch 9.1.1851: memory leak in heredoc_get()

Commit: 
https://github.com/vim/vim/commit/dc75a204f187176cec038a274e7920837029a56b
Author: Lidong Yan <[email protected]>
Date:   Sun Oct 12 15:05:11 2025 +0000

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/evalvars.c b/src/evalvars.c
index e529758ef..c840d872b 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -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);
        }
diff --git a/src/version.c b/src/version.c
index 3f6baf6bb..d46906ab2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1851,
 /**/
     1850,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1v7y1N-00AMtl-1x%40256bit.org.

Raspunde prin e-mail lui