In the unlikely case the parsing of genxml files fails, we were
leaking an xml parser object.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
len = fread(buf, 1, XML_BUFFER_SIZE, input);
if (len == 0) {
fprintf(stderr, "fread: %m\n");
- fclose(input);
- free(filename);
- return NULL;
+ free(ctx.spec);
+ ctx.spec = NULL;
+ goto end;
}
if (XML_ParseBuffer(ctx.parser, len, len == 0) == 0) {
fprintf(stderr,
XML_GetCurrentLineNumber(ctx.parser),
XML_GetCurrentColumnNumber(ctx.parser),
XML_ErrorString(XML_GetErrorCode(ctx.parser)));
- fclose(input);
- free(filename);
- return NULL;
+ free(ctx.spec);
+ ctx.spec = NULL;
+ goto end;
}
} while (len > 0);
+ end:
XML_ParserFree(ctx.parser);
fclose(input);