summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-08-05 16:47:08 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-05 16:47:08 +0200
commit1b6acf02b7e685ecb87ccba52c91835a7519073e (patch)
tree7fb86c549ad2794f1a08aedec9080ed74f3b9536
parent6a230c6b32695393785ae64b440ce5f023a22382 (diff)
downloadvim-git-1b6acf02b7e685ecb87ccba52c91835a7519073e.tar.gz
patch 8.2.3294: Lua: memory leak when adding dict item failsv8.2.3294
Problem: Lua: memory leak when adding dict item fails. Solution: Free the typval and the dict item.
-rw-r--r--src/if_lua.c10
-rw-r--r--src/version.c2
2 files changed, 11 insertions, 1 deletions
diff --git a/src/if_lua.c b/src/if_lua.c
index 144fcbea5..6ac395112 100644
--- a/src/if_lua.c
+++ b/src/if_lua.c
@@ -1859,12 +1859,20 @@ luaV_setvar(lua_State *L)
// Need to create an entry
di = dictitem_alloc((char_u *)name);
if (di == NULL)
+ {
+ clear_tv(&tv);
return 0;
+ }
// Update the value
copy_tv(&tv, &di->di_tv);
if (dict_add(dict, di) == FAIL)
+ {
+ dictitem_free(di);
+ clear_tv(&tv);
return luaL_error(L, "Couldn't add to dictionary");
- } else
+ }
+ }
+ else
{
// Clear the old value
clear_tv(&di->di_tv);
diff --git a/src/version.c b/src/version.c
index 2db7988ce..c2d3998ad 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3294,
+/**/
3293,
/**/
3292,