X-Git-Url: http://git.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=file.c;h=c6a30950cafc25a5c5f235974c91cb4df0b1f148;hp=1abe8ff4987d6159affc60c7f847ccb7f84d365c;hb=aa3ab8012bfbf793d2884c08ea924545a04e9544;hpb=79fe711a01cb1d0ac3b5f5603d21508eb1ffbd75 diff --git a/file.c b/file.c index 1abe8ff..c6a3095 100644 --- a/file.c +++ b/file.c @@ -442,19 +442,16 @@ void uci_file_commit(struct uci_context *ctx, struct uci_package **package, bool /* freed together with the uci_package */ path = NULL; - - /* check for updated history, flush */ - if (!uci_load_history(ctx, p, true)) - goto done; - } else { - /* flush history */ - if (!uci_load_history(ctx, NULL, true)) - goto done; } + + /* flush history */ + if (!uci_load_history(ctx, p, true)) + goto done; } rewind(f); - ftruncate(fileno(f), 0); + if (ftruncate(fileno(f), 0) < 0) + UCI_THROW(ctx, UCI_ERR_IO); uci_export(ctx, f, p, false); UCI_TRAP_RESTORE(ctx); @@ -497,8 +494,10 @@ static char **uci_list_config_files(struct uci_context *ctx) dir = uci_malloc(ctx, strlen(ctx->confdir) + 1 + sizeof("/*")); sprintf(dir, "%s/*", ctx->confdir); - if (glob(dir, GLOB_MARK, NULL, &globbuf) != 0) + if (glob(dir, GLOB_MARK, NULL, &globbuf) != 0) { + free(dir); UCI_THROW(ctx, UCI_ERR_NOTFOUND); + } size = sizeof(char *) * (globbuf.gl_pathc + 1); for(i = 0; i < globbuf.gl_pathc; i++) {