From 00b625a2ae75f344bafc85baf03a1b2ea73f8462 Mon Sep 17 00:00:00 2001 From: Jason C Date: Mon, 10 May 2021 19:01:15 -0400 Subject: [PATCH] [amf] Fix crash when file could not be parsed. Fix double free of mXmlParser (deleted but not reset in ParseFile, then deleted again in ~AMFImporter). Should probably use a smart pointer instead, though. --- This change was previously made in 785cca1bb43f9e6047cb566a910fcd0e3d49951f, as part of PR #3890, but was lost in a merge. --- code/AssetLib/AMF/AMFImporter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/AMF/AMFImporter.cpp b/code/AssetLib/AMF/AMFImporter.cpp index e77b65f77..615882b6a 100644 --- a/code/AssetLib/AMF/AMFImporter.cpp +++ b/code/AssetLib/AMF/AMFImporter.cpp @@ -268,7 +268,8 @@ void AMFImporter::ParseFile(const std::string &pFile, IOSystem *pIOHandler) { mXmlParser = new XmlParser(); if (!mXmlParser->parse(file.get())) { delete mXmlParser; - throw DeadlyImportError("Failed to create XML reader for file" + pFile + "."); + mXmlParser = nullptr; + throw DeadlyImportError("Failed to create XML reader for file ", pFile, "."); } // Start reading, search for root tag