From: Jo-Philipp Wich Date: Sun, 26 May 2013 16:55:20 +0000 (+0200) Subject: lua: emit a proper deletion when setting an existing list to a new list with only... X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=9ef6964362f917ba035020d439d05b36abfe5bb9;p=project%2Fuci.git lua: emit a proper deletion when setting an existing list to a new list with only a single item --- diff --git a/lua/uci.c b/lua/uci.c index 64e509e..6382900 100644 --- a/lua/uci.c +++ b/lua/uci.c @@ -551,6 +551,7 @@ uci_lua_set(lua_State *L) bool istable = false; int err = UCI_ERR_MEM; char *s = NULL; + const char *v; int i, nargs, offset = 0; ctx = find_context(L, &offset); @@ -597,8 +598,14 @@ uci_lua_set(lua_State *L) if (istable) { if (lua_objlen(L, nargs) == 1) { i = 1; - if (ptr.o) + if (ptr.o) { + v = ptr.value; + ptr.value = NULL; err = uci_delete(ctx, &ptr); + if (err) + goto error; + ptr.value = v; + } } else { i = 2; err = uci_set(ctx, &ptr);