Explorar o código

closes https://github.com/assimp/assimp/issues/3190 : fix leak.

kimkulling %!s(int64=5) %!d(string=hai) anos
pai
achega
5c9a08e375
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      include/assimp/metadata.h

+ 6 - 1
include/assimp/metadata.h

@@ -313,8 +313,13 @@ struct aiMetadata {
 
         // Set metadata type
         mValues[index].mType = GetAiType(value);
+
         // Copy the given value to the dynamic storage
-        mValues[index].mData = new T(value);
+        if (nullptr != mValues[index].mData) {
+            ::memcpy(mValues[index].mData, &value, sizeof(T));
+        } else {
+            mValues[index].mData = new T(value);
+        }
 
         return true;
     }