]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0136: memory leak in add_interface_from_super_class() v9.2.0136
authorHuihui Huang <625173@qq.com>
Tue, 10 Mar 2026 19:56:08 +0000 (19:56 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 10 Mar 2026 19:56:08 +0000 (19:56 +0000)
Problem:  memory leak in add_interface_from_super_class() in
          src/vim9class.c
Solution: Free variable intf_name in the error case, decrement the
          impl_gap grow array (Huihui Huang).

closes: #19629

Signed-off-by: Huihui Huang <625173@qq.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/version.c
src/vim9class.c

index cfe11e4c07facc4390e7a7c8017a67f436433d55..e58c12baa56965f996a8eb5987eeae66978ef518 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    136,
 /**/
     135,
 /**/
index 2148f0ffbd713d049ca9f65c8c79dd9822adbbbe..11696b72b6278f0f11a4d64fafbd60c34ef5c820 100644 (file)
@@ -918,7 +918,7 @@ add_interface_from_super_class(
        return FALSE;
 
     if (ga_grow(impl_gap, 1) == FAIL)
-       return FALSE;
+       goto fail;
 
     char_u **intf_names = (char_u **)impl_gap->ga_data;
     intf_names[impl_gap->ga_len] = intf_name;
@@ -926,7 +926,10 @@ add_interface_from_super_class(
 
     // Add the interface class to "intf_classes_gap"
     if (ga_grow(intf_classes_gap, 1) == FAIL)
-       return FALSE;
+    {
+       --impl_gap->ga_len;
+       goto fail;
+    }
 
     class_T **intf_classes = (class_T **)intf_classes_gap->ga_data;
     intf_classes[intf_classes_gap->ga_len] = ifcl;
@@ -934,6 +937,9 @@ add_interface_from_super_class(
     ++ifcl->class_refcount;
 
     return TRUE;
+fail:
+    vim_free(intf_name);
+    return FALSE;
 }
 
 /*