From 5c9a08e37546acd5d662e38bf4bb88a2ee554a58 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Mon, 4 May 2020 15:36:54 +0200 Subject: [PATCH] closes https://github.com/assimp/assimp/issues/3190 : fix leak. --- include/assimp/metadata.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/assimp/metadata.h b/include/assimp/metadata.h index cd7569ffe..3a50e3b58 100644 --- a/include/assimp/metadata.h +++ b/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; }