From 376fdc74c7207292ac9cc71c64f67a66bfd0cbfa Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 24 Oct 2013 23:24:32 +0200 Subject: [PATCH] file: fix memleak on mktemp() errors Signed-off-by: Felix Fietkau --- file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/file.c b/file.c index 509ed73..44b2e02 100644 --- a/file.c +++ b/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); -- 2.11.0