From 9ef6964362f917ba035020d439d05b36abfe5bb9 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 26 May 2013 18:55:20 +0200 Subject: [PATCH] lua: emit a proper deletion when setting an existing list to a new list with only a single item --- lua/uci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); -- 2.11.0