Browse Source

file: fix memleak on mktemp() errors

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Felix Fietkau 10 years ago
parent
commit
376fdc74c7
1 changed files with 3 additions and 1 deletions
  1. 3 1
      file.c

+ 3 - 1
file.c

@@ -703,8 +703,10 @@ static void uci_file_commit(struct uci_context *ctx, struct uci_package **packag
 		UCI_THROW(ctx, UCI_ERR_MEM);
 
 	mktemp(filename);
-	if (!*filename)
+	if (!*filename) {
+		free(filename);
 		UCI_THROW(ctx, UCI_ERR_IO);
+	}
 
 	if ((stat(filename, &statbuf) == 0) && ((statbuf.st_mode & S_IFMT) != S_IFREG))
 		UCI_THROW(ctx, UCI_ERR_IO);