X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=list.c;h=cd995fee2ff931da9d55d40f882555dc4e48058f;hp=adff0176402f74c1fbe846900e2094595f35deff;hb=97e71a1c1b0a9d50f2dc334e72c89153f8b87d45;hpb=defdac4bf39c2eca8d3def190c6eb6ca6bdf7723 diff --git a/list.c b/list.c index adff017..cd995fe 100644 --- a/list.c +++ b/list.c @@ -656,7 +656,7 @@ int uci_set(struct uci_context *ctx, struct uci_ptr *ptr) expand_ptr(ctx, ptr, false); UCI_ASSERT(ctx, ptr->value); UCI_ASSERT(ctx, ptr->s || (!ptr->option && ptr->section)); - if (!ptr->option) { + if (!ptr->option && ptr->value[0]) { UCI_ASSERT(ctx, uci_validate_type(ptr->value)); } @@ -666,7 +666,14 @@ int uci_set(struct uci_context *ctx, struct uci_ptr *ptr) if (e) ptr->o = uci_to_option(e); } - if (!ptr->o && ptr->option) { /* new option */ + if (!ptr->value[0]) { + /* if setting a nonexistant option/section to a nonexistant value, + * exit without errors */ + if (!(ptr->flags & UCI_LOOKUP_COMPLETE)) + return 0; + + return uci_delete(ctx, ptr); + } else if (!ptr->o && ptr->option) { /* new option */ ptr->o = uci_alloc_option(ptr->s, ptr->option, ptr->value); ptr->last = &ptr->o->e; } else if (!ptr->s && ptr->section) { /* new section */