From b35395fef15badf9a3788243e7ea0be388423f09 Mon Sep 17 00:00:00 2001 From: Murai Takashi Date: Fri, 24 Jan 2020 20:26:23 +0900 Subject: [PATCH] icon-o-matic: Fix resource leak When exception was thrown, resources allocated to 'fd' and 'p' weren't released. Fix PVS V773 Change-Id: I8a546cbbec4e5060b385cc11f0f33b63f61a0924 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2156 Reviewed-by: Adrien Destugues --- src/apps/icon-o-matic/import_export/svg/SVGParser.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp b/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp index d640d7e157..fcd182d472 100644 --- a/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp +++ b/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp @@ -335,6 +335,7 @@ Parser::parse(const char* pathToFile) FILE* fd = fopen(pathToFile, "r"); if (fd == 0) { sprintf(msg, "Couldn't open file %s", pathToFile); + XML_ParserFree(p); throw exception(msg); } @@ -346,6 +347,8 @@ Parser::parse(const char* pathToFile) sprintf(msg, "%s at line %ld\n", XML_ErrorString(XML_GetErrorCode(p)), XML_GetCurrentLineNumber(p)); + fclose(fd); + XML_ParserFree(p); throw exception(msg); } } while (!done);