瀏覽代碼

Fix a leak in FBXDocument when duplicate object IDs are found

When a duplicate ID is encountered, existing LazyObject is overwritten. Previously allocated instance leaks.

This change deletes the previously allocated instance before overwriting the pointer.
Anton Vaneev 2 年之前
父節點
當前提交
2cd3da4831
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      code/AssetLib/FBX/FBXDocument.cpp

+ 3 - 1
code/AssetLib/FBX/FBXDocument.cpp

@@ -381,8 +381,10 @@ void Document::ReadObjects() {
             DOMError("encountered object with implicitly defined id 0",el.second);
             DOMError("encountered object with implicitly defined id 0",el.second);
         }
         }
 
 
-        if(objects.find(id) != objects.end()) {
+        const auto foundObject = objects.find(id);
+        if(foundObject != objects.end()) {
             DOMWarning("encountered duplicate object id, ignoring first occurrence",el.second);
             DOMWarning("encountered duplicate object id, ignoring first occurrence",el.second);
+            delete foundObject->second;
         }
         }
 
 
         objects[id] = new LazyObject(id, *el.second, *this);
         objects[id] = new LazyObject(id, *el.second, *this);