ACK: [PATCH] lib: fwts_log: free filenames on error condition
Alex Hung
alex.hung at canonical.com
Wed May 8 02:00:08 UTC 2013
On 05/07/2013 02:58 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Coverity CID#997343: Resource leak
>
> We need to ensure filenames is free'd if it is already allocated
> if fwts_log_filename() fails.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/lib/src/fwts_log.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_log.c b/src/lib/src/fwts_log.c
> index 85748cb..4667a76 100644
> --- a/src/lib/src/fwts_log.c
> +++ b/src/lib/src/fwts_log.c
> @@ -579,8 +579,11 @@ char *fwts_log_get_filenames(const char *filename, const fwts_log_type type)
> for (i=0; i<32; i++) {
> fwts_log_type mask = 1 << i;
> if (type & mask) {
> - if ((tmp = fwts_log_filename(filename, mask)) == NULL)
> + if ((tmp = fwts_log_filename(filename, mask)) == NULL) {
> + if (filenames)
> + free(filenames);
> return NULL;
> + }
>
> if (filenames) {
> len += strlen(tmp) + 2;
>
Acked-by: Alex Hung <alex.hung at canonical.com>
More information about the fwts-devel
mailing list