2
0
Эх сурвалжийг харах

Sceneprecessor potential memory leak

Neil Clifford 4 жил өмнө
parent
commit
fc842a0f97

+ 12 - 0
code/Common/ScenePreprocessor.cpp

@@ -210,6 +210,10 @@ void ScenePreprocessor::ProcessAnimation(aiAnimation *anim) {
 
                 // No rotation keys? Generate a dummy track
                 if (!channel->mNumRotationKeys) {
+                    if (channel->mRotationKeys) {
+                        delete[] channel->mRotationKeys;
+                        channel->mRotationKeys = NULL;
+                    }
                     ai_assert(!channel->mRotationKeys);
                     channel->mNumRotationKeys = 1;
                     channel->mRotationKeys = new aiQuatKey[1];
@@ -225,6 +229,10 @@ void ScenePreprocessor::ProcessAnimation(aiAnimation *anim) {
 
                 // No scaling keys? Generate a dummy track
                 if (!channel->mNumScalingKeys) {
+                    if (channel->mScalingKeys) {
+                        delete[] channel->mScalingKeys;
+                        channel->mScalingKeys = NULL;
+                    }
                     ai_assert(!channel->mScalingKeys);
                     channel->mNumScalingKeys = 1;
                     channel->mScalingKeys = new aiVectorKey[1];
@@ -240,6 +248,10 @@ void ScenePreprocessor::ProcessAnimation(aiAnimation *anim) {
 
                 // No position keys? Generate a dummy track
                 if (!channel->mNumPositionKeys) {
+                    if (channel->mPositionKeys) {
+                        delete[] channel->mPositionKeys;
+                        channel->mPositionKeys = NULL;
+                    }
                     ai_assert(!channel->mPositionKeys);
                     channel->mNumPositionKeys = 1;
                     channel->mPositionKeys = new aiVectorKey[1];