]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1125: memory leak when using class functions v9.0.1125
authorBram Moolenaar <Bram@vim.org>
Sun, 1 Jan 2023 14:11:27 +0000 (14:11 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 1 Jan 2023 14:11:27 +0000 (14:11 +0000)
Problem:    Memory leak when using class functions.
Solution:   Clear and free the array with class functions.

src/version.c
src/vim9class.c

index b49d71d8c8f4d5c0291f74716c92af62f8518db6..5688d0d7bc20987b8fdb7104b0b60ac47c2e4f52 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1125,
 /**/
     1124,
 /**/
index b1de90b8b7a3e3c81c9270c9db4e9382a716b3ac..b05dea8eff3931bcb76463639caf25c8774852a2 100644 (file)
@@ -975,6 +975,13 @@ class_unref(class_T *cl)
        }
        vim_free(cl->class_obj_members);
 
+       for (int i = 0; i < cl->class_class_function_count; ++i)
+       {
+           ufunc_T *uf = cl->class_class_functions[i];
+           func_clear_free(uf, FALSE);
+       }
+       vim_free(cl->class_class_functions);
+
        for (int i = 0; i < cl->class_obj_method_count; ++i)
        {
            ufunc_T *uf = cl->class_obj_methods[i];