Merge pull request #5067 from assimp/kimkulling/fix_memory_leak_in_fbx_scope_issue-3421

Fix: Fix leak in Scope class, FBX
pull/5043/head^2
Kim Kulling 2023-04-17 20:40:46 +02:00 committed by GitHub
commit 0023f9b09a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -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));
}
}
}