Re: [PATCH v2 2/2] test: Fix issues reported by cppcheck static analysis tool

Bertram Felgenhauer <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <20140821191804.GD18869@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f>
Ravi Nanjundappa wrote:
> @@ -71,11 +71,15 @@ read_file (const cairo_test_context_t *ctx,
>      *len = ftell(fp);
>      fseek (fp, 0, SEEK_SET);
>      *data = malloc (*len);
> -    if (*data == NULL)
> +    if (*data == NULL) {
> +	fclose(fp);
>  	return CAIRO_TEST_NO_MEMORY;
> +    }
>  
> -    if (fread(*data, *len, 1, fp) != 1)
> +    if (fread(*data, *len, 1, fp) != 1) {
> +	fclose(fp);
>  	return CAIRO_TEST_FAILURE;
> +    }

shouldn't there be a 'free(data)' here, too?

Cheers,

Bertram
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.