--- libgig/trunk/src/RIFF.cpp 2009/03/13 10:57:24 1863 +++ libgig/trunk/src/RIFF.cpp 2009/03/22 11:13:25 1869 @@ -94,7 +94,7 @@ } Chunk::~Chunk() { - pFile->UnlogResized(this); + if (pFile) pFile->UnlogResized(this); if (pChunkData) delete[] pChunkData; } @@ -950,6 +950,10 @@ #if DEBUG std::cout << "List::~List()" << std::endl; #endif // DEBUG + DeleteChunkList(); + } + + void List::DeleteChunkList() { if (pSubChunks) { ChunkList::iterator iter = pSubChunks->begin(); ChunkList::iterator end = pSubChunks->end(); @@ -958,8 +962,12 @@ iter++; } delete pSubChunks; + pSubChunks = NULL; + } + if (pSubChunksMap) { + delete pSubChunksMap; + pSubChunksMap = NULL; } - if (pSubChunksMap) delete pSubChunksMap; } /** @@ -1755,6 +1763,8 @@ #else if (hFileRead) fclose(hFileRead); #endif // POSIX + DeleteChunkList(); + pFile = NULL; } void File::LogAsResized(Chunk* pResizedChunk) {