From 5b18bb1aa13e7da895b58a4e413797587365cf96 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 18 Sep 2010 12:42:23 +0000 Subject: SWORD2: Plug memory leaks. svn-id: r52795 --- engines/sword2/sprite.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines/sword2/sprite.cpp') diff --git a/engines/sword2/sprite.cpp b/engines/sword2/sprite.cpp index 5a45c19ab6..7d45f8df4e 100644 --- a/engines/sword2/sprite.cpp +++ b/engines/sword2/sprite.cpp @@ -528,8 +528,11 @@ int32 Screen::drawSprite(SpriteInfo *s) { decompData = decompressHIF(s->data, tempBuf); // Check that we correctly decompressed data - if (!decompData) + if (!decompData) { + free(tempBuf); + return RDERR_DECOMPRESSION; + } s->w = (decompData / (s->h / 2)) * 2; byte *tempBuf2 = (byte *)malloc(s->w * s->h * 10); @@ -571,8 +574,11 @@ int32 Screen::drawSprite(SpriteInfo *s) { uint32 decompData = decompressHIF(s->data, tempBuf); // Check that we correctly decompressed data - if (!decompData) + if (!decompData) { + free(tempBuf); + return RDERR_DECOMPRESSION; + } s->w = (decompData / (s->h / 2)); sprite = (byte *)malloc(s->w * s->h); -- cgit v1.2.3