patch 9.2.0136: memory leak in add_interface_from_super_class()

Commit: 
https://github.com/vim/vim/commit/93a7855f01b61fafd2063481252ece7cb6fe6b0c
Author: Huihui Huang <[email protected]>
Date:   Tue Mar 10 19:56:08 2026 +0000

    patch 9.2.0136: memory leak in add_interface_from_super_class()
    
    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/version.c b/src/version.c
index cfe11e4c0..e58c12baa 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    136,
 /**/
     135,
 /**/
diff --git a/src/vim9class.c b/src/vim9class.c
index 2148f0ffb..11696b72b 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -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;
 }
 
 /*

-- 
-- 
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/E1w03FO-00GX0V-UV%40256bit.org.

Raspunde prin e-mail lui