patch 9.2.0258: memory leak in add_mark()

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>
This commit is contained in:
Huihui Huang
2026-03-26 20:59:03 +00:00
committed by Christian Brabandt
parent 02abcf381f
commit b90145672d
2 changed files with 6 additions and 0 deletions
+4
View 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;
}
+2
View File
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
258,
/**/
257,
/**/