From 07b4fdcf9665de74653ac19cbeb3ee3fa38ceaa4 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 30 Jan 2008 00:38:53 +0100 Subject: [PATCH] extra checks --- file.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/file.c b/file.c index 0e5992c..a0fe58b 100644 --- a/file.c +++ b/file.c @@ -621,7 +621,7 @@ static void uci_parse_history(struct uci_context *ctx, FILE *stream, struct uci_ static void uci_load_history(struct uci_context *ctx, struct uci_package *p) { - char *filename; + char *filename = NULL; FILE *f = NULL; if (!p->confdir) @@ -634,6 +634,8 @@ static void uci_load_history(struct uci_context *ctx, struct uci_package *p) uci_parse_history(ctx, f, p); UCI_TRAP_RESTORE(ctx); done: + if (filename) + free(filename); uci_close_stream(f); ctx->errno = 0; } @@ -802,11 +804,7 @@ char **uci_list_configs(struct uci_context *ctx) size += strlen(p) + 1; } - configs = malloc(size); - if (!configs) - return NULL; - - memset(configs, 0, size); + configs = uci_malloc(ctx, size); buf = (char *) &configs[globbuf.gl_pathc + 1]; for(i = 0; i < globbuf.gl_pathc; i++) { char *p; -- 2.25.1