From 55be6653e014e48a5c9cb4977c81c1d7d7b037ab Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Fri, 12 May 2017 10:49:46 +0100 Subject: [PATCH] intel: gen-decoder: fix xml parser leak MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In the unlikely case the parsing of genxml files fails, we were leaking an xml parser object. Signed-off-by: Lionel Landwerlin Reviewed-by: Tapani Pälli --- src/intel/common/gen_decoder.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c index 24147340f58..35aa9f63ffa 100644 --- a/src/intel/common/gen_decoder.c +++ b/src/intel/common/gen_decoder.c @@ -650,9 +650,9 @@ gen_spec_load_from_path(const struct gen_device_info *devinfo, 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, @@ -660,12 +660,13 @@ gen_spec_load_from_path(const struct gen_device_info *devinfo, 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); -- 2.30.2