From: wise86Android Date: Sun, 17 Jan 2016 14:18:12 +0000 (+0100) Subject: fix memory leak X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7f69e151e914e5aa5a8e67711ac68e7af7b6689;p=platform%2Fupstream%2Fassimp.git fix memory leak --- diff --git a/code/SkeletonMeshBuilder.cpp b/code/SkeletonMeshBuilder.cpp index 6108ac1..a3ef75b 100644 --- a/code/SkeletonMeshBuilder.cpp +++ b/code/SkeletonMeshBuilder.cpp @@ -73,9 +73,11 @@ SkeletonMeshBuilder::SkeletonMeshBuilder( aiScene* pScene, aiNode* root, bool bK root->mMeshes[0] = 0; // create a dummy material for the mesh - pScene->mNumMaterials = 1; - pScene->mMaterials = new aiMaterial*[1]; - pScene->mMaterials[0] = CreateMaterial(); + if(pScene->mNumMaterials==0){ + pScene->mNumMaterials = 1; + pScene->mMaterials = new aiMaterial*[1]; + pScene->mMaterials[0] = CreateMaterial(); + } } // ------------------------------------------------------------------------------------------------ diff --git a/test/unit/utColladaExportLight.cpp b/test/unit/utColladaExportLight.cpp index 2d6497f..5edf3e9 100644 --- a/test/unit/utColladaExportLight.cpp +++ b/test/unit/utColladaExportLight.cpp @@ -54,7 +54,6 @@ public: { ex = new Assimp::Exporter(); im = new Assimp::Importer(); - } virtual void TearDown() @@ -73,7 +72,7 @@ protected: // ------------------------------------------------------------------------------------------------ TEST_F(ColladaExportLight, testExportLight) { - const char* file = "cameraExp.dae"; + const char* file = "lightsExp.dae"; const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/lights.dae",0); ASSERT_TRUE(pTest!=NULL); @@ -88,7 +87,6 @@ TEST_F(ColladaExportLight, testExportLight) } EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file)); - EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada","lightsExp.dae")); const aiScene* imported = im->ReadFile(file,0); @@ -123,7 +121,9 @@ TEST_F(ColladaExportLight, testExportLight) EXPECT_NEAR(orig->mAngleInnerCone,read->mAngleInnerCone,0.001); EXPECT_NEAR(orig->mAngleOuterCone,read->mAngleOuterCone,0.001); } + delete [] origLights; + }