uci: Fix uci_delete() when ptr->value is empty string
authorKrzysztof Kuźnik <k.kuznik@avsystem.com>
Thu, 28 Feb 2013 13:44:00 +0000 (13:44 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 2 May 2013 12:30:31 +0000 (14:30 +0200)
After fix for deleting list elements by index this function was
broken and didn't allow to invoke from command line:
uci set some.fancy.list=''
i.e. list wasn't cleared

Signed-off-by: Krzysztof Kuźnik <k.kuznik@avsystem.com>
list.c

diff --git a/list.c b/list.c
index f47b5a83655729e00d46ba6b73daf852f453f50c..f3a9ed6fa8566a8b30f83bbf61ba371b42ade08c 100644 (file)
--- a/list.c
+++ b/list.c
@@ -559,7 +559,7 @@ int uci_delete(struct uci_context *ctx, struct uci_ptr *ptr)
 
        UCI_ASSERT(ctx, ptr->s);
 
-       if (ptr->value && ptr->o && ptr->o->type == UCI_TYPE_LIST) {
+       if (ptr->value && *ptr->value && ptr->o && ptr->o->type == UCI_TYPE_LIST) {
                if (!sscanf(ptr->value, "%d", &index))
                        return 1;