From: Felix Fietkau Date: Sun, 3 Feb 2008 06:37:20 +0000 (+0100) Subject: fix a few bugs found during code review X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cf66ea9067d3e9ffe77f42723c5b2f9d38b05ecf;p=oweals%2Fuci.git fix a few bugs found during code review --- diff --git a/history.c b/history.c index 0526361..dcf94e0 100644 --- a/history.c +++ b/history.c @@ -82,7 +82,7 @@ static void uci_parse_history_line(struct uci_context *ctx, struct uci_package * goto error; if (option && !uci_validate_name(option)) goto error; - if ((rename || !delete) && !uci_validate_name(value)) + if ((rename || (!option && !delete)) && !uci_validate_name(value)) goto error; if (rename) diff --git a/libuci.c b/libuci.c index fd8f30c..66e6d23 100644 --- a/libuci.c +++ b/libuci.c @@ -71,6 +71,7 @@ void uci_free_context(struct uci_context *ctx) free(ctx->savedir); UCI_TRAP_SAVE(ctx, ignore); + ctx->internal = true; uci_cleanup(ctx); uci_foreach_element_safe(&ctx->root, tmp, e) { struct uci_package *p = uci_to_package(e); diff --git a/list.c b/list.c index 502f51f..a0d50d1 100644 --- a/list.c +++ b/list.c @@ -163,7 +163,7 @@ uci_add_history(struct uci_context *ctx, struct uci_package *p, int cmd, char *s return; if (value) - size += strlen(section) + 1; + size += strlen(value) + 1; h = uci_alloc_element(ctx, history, option, size); ptr = uci_dataptr(h); @@ -446,7 +446,7 @@ int uci_set(struct uci_context *ctx, struct uci_package *p, char *section, char goto notfound; s = uci_to_section(e); - if (ctx->pctx) + if (ctx->pctx && ctx->pctx->merge) ctx->pctx->section = s; if (option) { @@ -485,7 +485,7 @@ notfound: uci_alloc_option(s, option, value); else { s = uci_alloc_section(p, value, section); - if (ctx->pctx) + if (ctx->pctx && ctx->pctx->merge) ctx->pctx->section = s; }