X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=history.c;h=a31dbfaf1cb23d5ed196e4f6cbc66daf0a4ea042;hp=ae66f66c0f60ff8bcc4e54a283e83b48793ce252;hb=213d8d8934f797849eb80b7ac06b6d37f3090e40;hpb=29bdad8620257c45dcbff5d15f26ac0b61c7b419 diff --git a/history.c b/history.c index ae66f66..a31dbfa 100644 --- a/history.c +++ b/history.c @@ -160,7 +160,8 @@ static void uci_parse_history_line(struct uci_context *ctx, struct uci_package * break; case UCI_CMD_ADD: case UCI_CMD_CHANGE: - UCI_INTERNAL(uci_set, ctx, p, ptr.section, ptr.option, ptr.value, &e); + UCI_INTERNAL(uci_set, ctx, &ptr); + e = ptr.last; if (!ptr.option && e && (cmd == UCI_CMD_ADD)) uci_to_section(e)->anonymous = true; break; @@ -317,7 +318,7 @@ static void uci_filter_history(struct uci_context *ctx, const char *name, const done: if (filename) free(filename); - uci_close_stream(f); + uci_close_stream(pctx->file); uci_foreach_element_safe(&list, tmp, e) { uci_free_element(e); } @@ -331,7 +332,7 @@ int uci_revert(struct uci_context *ctx, struct uci_ptr *ptr) char *option = NULL; UCI_HANDLE_ERR(ctx); - expand_ptr(ctx, ptr, true); + expand_ptr(ctx, ptr, false); UCI_ASSERT(ctx, ptr->p->has_history); /* @@ -347,8 +348,10 @@ int uci_revert(struct uci_context *ctx, struct uci_ptr *ptr) /* NB: need to clone package, section and option names, * as they may get freed on uci_free_package() */ package = uci_strdup(ctx, ptr->p->e.name); - section = uci_strdup(ctx, ptr->section); - option = uci_strdup(ctx, ptr->option); + if (ptr->section) + section = uci_strdup(ctx, ptr->section); + if (ptr->option) + option = uci_strdup(ctx, ptr->option); uci_free_package(&ptr->p); uci_filter_history(ctx, package, section, option);