122243,122194 Resource leak
parent
61097479c8
commit
3f53ffa576
|
@ -127,8 +127,7 @@ void HMPImporter::InternReadFile( const std::string& pFile,
|
||||||
throw DeadlyImportError( "HMP File is too small.");
|
throw DeadlyImportError( "HMP File is too small.");
|
||||||
|
|
||||||
// Allocate storage and copy the contents of the file to a memory buffer
|
// Allocate storage and copy the contents of the file to a memory buffer
|
||||||
std::vector<uint8_t> buffer(fileSize);
|
mBuffer = new uint8_t[fileSize];
|
||||||
mBuffer = &buffer[0];
|
|
||||||
file->Read( (void*)mBuffer, 1, fileSize);
|
file->Read( (void*)mBuffer, 1, fileSize);
|
||||||
iFileSize = (unsigned int)fileSize;
|
iFileSize = (unsigned int)fileSize;
|
||||||
|
|
||||||
|
@ -174,7 +173,9 @@ void HMPImporter::InternReadFile( const std::string& pFile,
|
||||||
// Set the AI_SCENE_FLAGS_TERRAIN bit
|
// Set the AI_SCENE_FLAGS_TERRAIN bit
|
||||||
pScene->mFlags |= AI_SCENE_FLAGS_TERRAIN;
|
pScene->mFlags |= AI_SCENE_FLAGS_TERRAIN;
|
||||||
|
|
||||||
// File buffer destructs automatically now
|
delete[] mBuffer;
|
||||||
|
mBuffer= nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -449,11 +450,13 @@ void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char* szC
|
||||||
|
|
||||||
// read the type of the skin ...
|
// read the type of the skin ...
|
||||||
// sometimes we need to skip 12 bytes here, I don't know why ...
|
// sometimes we need to skip 12 bytes here, I don't know why ...
|
||||||
uint32_t iType = *((uint32_t*)szCursor);szCursor += sizeof(uint32_t);
|
uint32_t iType = *((uint32_t*)szCursor);
|
||||||
|
szCursor += sizeof(uint32_t);
|
||||||
if (0 == iType)
|
if (0 == iType)
|
||||||
{
|
{
|
||||||
szCursor += sizeof(uint32_t) * 2;
|
szCursor += sizeof(uint32_t) * 2;
|
||||||
iType = *((uint32_t*)szCursor);szCursor += sizeof(uint32_t);
|
iType = *((uint32_t*)szCursor);
|
||||||
|
szCursor += sizeof(uint32_t);
|
||||||
if (!iType)
|
if (!iType)
|
||||||
throw DeadlyImportError("Unable to read HMP7 skin chunk");
|
throw DeadlyImportError("Unable to read HMP7 skin chunk");
|
||||||
|
|
||||||
|
|
|
@ -172,8 +172,7 @@ void MDLImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate storage and copy the contents of the file to a memory buffer
|
// Allocate storage and copy the contents of the file to a memory buffer
|
||||||
std::vector<unsigned char> buffer(iFileSize+1);
|
mBuffer =new unsigned char[iFileSize+1];
|
||||||
mBuffer = &buffer[0];
|
|
||||||
file->Read( (void*)mBuffer, 1, iFileSize);
|
file->Read( (void*)mBuffer, 1, iFileSize);
|
||||||
|
|
||||||
// Append a binary zero to the end of the buffer.
|
// Append a binary zero to the end of the buffer.
|
||||||
|
@ -239,7 +238,8 @@ void MDLImporter::InternReadFile( const std::string& pFile,
|
||||||
0.f,0.f,1.f,0.f,0.f,-1.f,0.f,0.f,0.f,0.f,0.f,1.f);
|
0.f,0.f,1.f,0.f,0.f,-1.f,0.f,0.f,0.f,0.f,0.f,1.f);
|
||||||
|
|
||||||
// delete the file buffer and cleanup
|
// delete the file buffer and cleanup
|
||||||
AI_DEBUG_INVALIDATE_PTR(mBuffer);
|
delete [] mBuffer;
|
||||||
|
mBuffer= nullptr;
|
||||||
AI_DEBUG_INVALIDATE_PTR(pIOHandler);
|
AI_DEBUG_INVALIDATE_PTR(pIOHandler);
|
||||||
AI_DEBUG_INVALIDATE_PTR(pScene);
|
AI_DEBUG_INVALIDATE_PTR(pScene);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue