]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0258: memory leak in add_mark() v9.2.0258
authorHuihui Huang <625173@qq.com>
Thu, 26 Mar 2026 20:59:03 +0000 (20:59 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 26 Mar 2026 20:59:03 +0000 (20:59 +0000)
Problem:  memory leak in add_mark()
Solution: Free lpos in the error case when it hasn't been added to the
          dict yet (Huihui Huang)

closes: #19827

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

index c872e2f0ffff085682b5595eadf5762f0bc2ef9a..7cd4f31bcbcbf4fe4ed47de87d35ddb2036cfd63 100644 (file)
@@ -1484,7 +1484,11 @@ add_mark(list_T *l, char_u *mname, pos_T *pos, int bufnr, char_u *fname)
     if (dict_add_string(d, "mark", mname) == FAIL
            || dict_add_list(d, "pos", lpos) == FAIL
            || (fname != NULL && dict_add_string(d, "file", fname) == FAIL))
+    {
+       if (lpos->lv_refcount == 0)
+           list_free(lpos);
        return FAIL;
+    }
 
     return OK;
 }
index 770e09b8609f8f476a88ef53d226d0494488c530..8b35a87905a2f575aa63b677dbaf513b8b60aead 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    258,
 /**/
     257,
 /**/