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

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Thu Aug 21 12:18:04 PDT 2014


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


More information about the cairo mailing list