summaryrefslogtreecommitdiff
path: root/src/if_lua.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/if_lua.c')
-rw-r--r--src/if_lua.c10
1 files changed, 9 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);