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

Alex Hung alex.hung at canonical.com
Wed May 8 02:10:57 UTC 2013


On 05/07/2013 03:03 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> overity 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 | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/src/lib/src/fwts_log.c b/src/lib/src/fwts_log.c
> index 4667a76..41214da 100644
> --- a/src/lib/src/fwts_log.c
> +++ b/src/lib/src/fwts_log.c
> @@ -674,6 +674,7 @@ fwts_log *fwts_log_open(
>
>   				if (log_file->fp == NULL) {
>   					fwts_log_close(newlog);
> +					free(log_file);
>   					return NULL;
>   				}
>   			}
>

The patch looks good. Is it also needed to free(log_file) in the below 
if-statement just a little above?

if ((newname = fwts_log_filename(filename, mask)) == NULL) {
     fwts_log_close(newlog);
     return NULL;
}




More information about the fwts-devel mailing list