From ca937788ee10ed86646fd04e53f1111f65abea95 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 17 Apr 2023 20:08:58 +0200 Subject: [PATCH] Fix: Fix leak in Scope class, FBX - closes https://github.com/assimp/assimp/issues/3421 --- code/AssetLib/FBX/FBXParser.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/FBX/FBXParser.cpp b/code/AssetLib/FBX/FBXParser.cpp index d71321452..a8e766873 100644 --- a/code/AssetLib/FBX/FBXParser.cpp +++ b/code/AssetLib/FBX/FBXParser.cpp @@ -188,15 +188,19 @@ Scope::Scope(Parser& parser,bool topLevel) ParseError("unexpected content: empty string."); } - elements.insert(ElementMap::value_type(str,new_Element(*n,parser))); - + auto *element = new_Element(*n, parser); + // Element() should stop at the next Key token (or right after a Close token) n = parser.CurrentToken(); if (n == nullptr) { if (topLevel) { + elements.insert(ElementMap::value_type(str, element)); return; } ParseError("unexpected end of file",parser.LastToken()); + delete element; + } else { + elements.insert(ElementMap::value_type(str, element)); } } }