瀏覽代碼

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

Fix: Fix leak in Scope class, FBX
Kim Kulling 2 年之前
父節點
當前提交
0023f9b09a
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      code/AssetLib/FBX/FBXParser.cpp

+ 6 - 2
code/AssetLib/FBX/FBXParser.cpp

@@ -188,15 +188,19 @@ Scope::Scope(Parser& parser,bool topLevel)
             ParseError("unexpected content: empty string.");
             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)
         // Element() should stop at the next Key token (or right after a Close token)
         n = parser.CurrentToken();
         n = parser.CurrentToken();
         if (n == nullptr) {
         if (n == nullptr) {
             if (topLevel) {
             if (topLevel) {
+                elements.insert(ElementMap::value_type(str, element));
                 return;
                 return;
             }
             }
             ParseError("unexpected end of file",parser.LastToken());
             ParseError("unexpected end of file",parser.LastToken());
+            delete element;
+        } else {
+            elements.insert(ElementMap::value_type(str, element));
         }
         }
     }
     }
 }
 }