Skip to content

Commit 1b6acf0

Browse files
committed
patch 8.2.3294: Lua: memory leak when adding dict item fails
Problem: Lua: memory leak when adding dict item fails. Solution: Free the typval and the dict item.
1 parent 6a230c6 commit 1b6acf0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/if_lua.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1859,12 +1859,20 @@ luaV_setvar(lua_State *L)
18591859
// Need to create an entry
18601860
di = dictitem_alloc((char_u *)name);
18611861
if (di == NULL)
1862+
{
1863+
clear_tv(&tv);
18621864
return 0;
1865+
}
18631866
// Update the value
18641867
copy_tv(&tv, &di->di_tv);
18651868
if (dict_add(dict, di) == FAIL)
1869+
{
1870+
dictitem_free(di);
1871+
clear_tv(&tv);
18661872
return luaL_error(L, "Couldn't add to dictionary");
1867-
} else
1873+
}
1874+
}
1875+
else
18681876
{
18691877
// Clear the old value
18701878
clear_tv(&di->di_tv);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3294,
758760
/**/
759761
3293,
760762
/**/

0 commit comments

Comments
 (0)