From 4acad22d6e28d647c3233c183e3104b9d02a86e5 Mon Sep 17 00:00:00 2001 From: David Turner Date: Sun, 7 Nov 2010 21:08:46 +0000 Subject: TOON: Corrections to close some memory leaks. These corrections close a number of leaks in the Toon engine reported by running Valgrind with --leak-check=full option. svn-id: r54127 --- engines/toon/anim.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'engines/toon/anim.cpp') diff --git a/engines/toon/anim.cpp b/engines/toon/anim.cpp index 53980e3dc1..169d53de5d 100644 --- a/engines/toon/anim.cpp +++ b/engines/toon/anim.cpp @@ -58,6 +58,7 @@ bool Animation::loadAnimation(Common::String file) { uint8 *currentData = fileData + 68; if (_paletteEntries) { if (paletteSize) { + delete[] _palette; _palette = new uint8[paletteSize]; memcpy(_palette, currentData, paletteSize); currentData += paletteSize; @@ -74,6 +75,7 @@ bool Animation::loadAnimation(Common::String file) { if (READ_LE_UINT32(finalBuffer) == 0x12345678) { uint8 *data = finalBuffer; + delete[] _frames; _frames = new AnimationFrame[_numFrames]; for (int32 e = 0; e < _numFrames; e++) { if (READ_LE_UINT32(data) != 0x12345678) @@ -111,8 +113,9 @@ bool Animation::loadAnimation(Common::String file) { } Animation::Animation(ToonEngine *vm) : _vm(vm) { - _palette = 0; - _frames = 0; + _palette = NULL; + _numFrames = 0; + _frames = NULL; } Animation::~Animation() { -- cgit v1.2.3