diff --git a/code/MaterialSystem.cpp b/code/MaterialSystem.cpp index dc8f5fc5e..aa17d5458 100644 --- a/code/MaterialSystem.cpp +++ b/code/MaterialSystem.cpp @@ -482,8 +482,9 @@ aiReturn aiMaterial::AddBinaryProperty (const void* pInput, aiMaterialProperty** ppTemp; try { - ppTemp = new aiMaterialProperty*[mNumAllocated]; + ppTemp = new aiMaterialProperty*[mNumAllocated]; } catch (std::bad_alloc&) { + delete pcNew; return AI_OUTOFMEMORY; } diff --git a/tools/assimp_cmd/CompareDump.cpp b/tools/assimp_cmd/CompareDump.cpp index 26f2cd3ce..8739c9364 100644 --- a/tools/assimp_cmd/CompareDump.cpp +++ b/tools/assimp_cmd/CompareDump.cpp @@ -892,12 +892,33 @@ int Assimp_CompareDump (const char* const* params, unsigned int num) return 0; } - FILE* actual = fopen(params[0],"rb"), *expected = fopen(params[1],"rb"); + class file_ptr + { + public: + file_ptr(FILE *p) + : m_file(p) + {} + ~file_ptr() + { + if (m_file) + { + fclose(m_file); + m_file = NULL; + } + } + + operator FILE *() { return m_file; } + + private: + FILE *m_file; + }; + file_ptr actual(fopen(params[0],"rb")); if (!actual) { std::cout << "assimp cmpdump: Failure reading ACTUAL data from " << params[0] << std::endl; return -5; } + file_ptr expected(fopen(params[1],"rb")); if (!expected) { std::cout << "assimp cmpdump: Failure reading EXPECT data from " << params[1] << std::endl;