]> pilppa.com Git - uci.git/commitdiff
memory leak fix, for config file load case
authorMika Laitio <lamikr@pilppa.org>
Sat, 25 Dec 2010 23:06:33 +0000 (01:06 +0200)
committerMika Laitio <lamikr@pilppa.org>
Sat, 25 Dec 2010 23:06:33 +0000 (01:06 +0200)
Signed-off-by: Mika Laitio <lamikr@pilppa.org>
file.c

diff --git a/file.c b/file.c
index af42a3787973a6350d5ac12c77a3d9d914554727..867984120b6c250b71e5a3a3f6436d13568cb71c 100644 (file)
--- a/file.c
+++ b/file.c
@@ -808,7 +808,7 @@ static char **uci_list_config_files(struct uci_context *ctx)
 static struct uci_package *uci_file_load(struct uci_context *ctx, const char *name)
 {
        struct uci_package *package = NULL;
-       char *filename;
+       char *filename = NULL;
        bool confdir;
        FILE *file = NULL;
 
@@ -845,8 +845,10 @@ static struct uci_package *uci_file_load(struct uci_context *ctx, const char *na
 
 done:
        uci_close_stream(file);
-       if (ctx->err)
+       if (ctx->err) {
+               free(filename);
                UCI_THROW(ctx, ctx->err);
+       }
        return package;
 }