]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0801: Memory leak in f_getreginfo() on alloc failure v9.2.0801
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Sat, 18 Jul 2026 14:35:21 +0000 (14:35 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 18 Jul 2026 14:35:21 +0000 (14:35 +0000)
Problem:  Memory leak in f_getreginfo() on alloc failure
Solution: Call list_unref() with list var (Yasuhiro Matsumoto).

Since dict_add_list() leaves ownership with the caller on failure, the
freshly built list must be freed when the add fails.

related: #20668
related: #20745

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/evalfunc.c
src/version.c

index 15b1eee8738629c151535bd7dbcf675d5e053c56..de52668e5b7b3e2a5d805ac775ab6bfeb78bdbdd 100644 (file)
@@ -10569,7 +10569,8 @@ f_getreginfo(typval_T *argvars, typval_T *rettv)
     list = (list_T *)get_reg_contents(regname, GREG_EXPR_SRC | GREG_LIST);
     if (list == NULL)
        return;
-    (void)dict_add_list(dict, "regcontents", list);
+    if (dict_add_list(dict, "regcontents", list) == FAIL)
+       list_unref(list);
 
     switch (get_reg_type(regname, &reglen))
     {
index 801fd417976beb8568e65f1dbc7d44e85458a3d6..e5eaed8d967b2b5d1ef3866d13ab3612ee693820 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    801,
 /**/
     800,
 /**/