From 5278e1a5f85dc51f5e0f4c2be28e5b4fffce0227 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 3 Feb 2018 17:52:25 +0200 Subject: [PATCH] CSM: Fix a possible memory leak by using std::unique_ptr --- code/CSMLoader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/CSMLoader.cpp b/code/CSMLoader.cpp index 7b0064164..7160740c1 100644 --- a/code/CSMLoader.cpp +++ b/code/CSMLoader.cpp @@ -136,7 +136,7 @@ void CSMImporter::InternReadFile( const std::string& pFile, TextFileToBuffer(file.get(),mBuffer2); const char* buffer = &mBuffer2[0]; - aiAnimation* anim = new aiAnimation(); + std::unique_ptr anim(new aiAnimation()); int first = 0, last = 0x00ffffff; // now process the file and look out for '$' sections @@ -294,8 +294,8 @@ void CSMImporter::InternReadFile( const std::string& pFile, // Store the one and only animation in the scene pScene->mAnimations = new aiAnimation*[pScene->mNumAnimations=1]; - pScene->mAnimations[0] = anim; anim->mName.Set("$CSM_MasterAnim"); + pScene->mAnimations[0] = anim.release(); // mark the scene as incomplete and run SkeletonMeshBuilder on it pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;