[PATCH][V2] lib: fwts_log: free log_file on error exit

Colin King colin.king at canonical.com
Wed May 8 06:55:01 UTC 2013


From: Colin Ian King <colin.king at canonical.com>

Coverity CID#997342: Resource leak

log_file needs to be free'd on log_file->fp == NULL error
condition.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/lib/src/fwts_log.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/lib/src/fwts_log.c b/src/lib/src/fwts_log.c
index 4667a76..b4a36ec 100644
--- a/src/lib/src/fwts_log.c
+++ b/src/lib/src/fwts_log.c
@@ -667,6 +667,7 @@ fwts_log *fwts_log_open(
 			case LOG_FILENAME_TYPE_FILE:
 				if ((newname = fwts_log_filename(filename, mask)) == NULL) {
 					fwts_log_close(newlog);
+					free(log_file);
 					return NULL;
 				}
 				log_file->fp = fopen(newname, mode);
@@ -674,6 +675,7 @@ fwts_log *fwts_log_open(
 
 				if (log_file->fp == NULL) {
 					fwts_log_close(newlog);
+					free(log_file);
 					return NULL;
 				}
 			}
-- 
1.8.1.2




More information about the fwts-devel mailing list