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