From f0b3a13ed5e25d5b4559b14f7ca0251c9e63b25f Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Tue, 30 Aug 2016 05:38:56 +0300 Subject: [PATCH] Fixed memory leak in CCreatureAnimation --- client/battle/CCreatureAnimation.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/battle/CCreatureAnimation.cpp b/client/battle/CCreatureAnimation.cpp index 20c04deaf..f9c71aa4f 100644 --- a/client/battle/CCreatureAnimation.cpp +++ b/client/battle/CCreatureAnimation.cpp @@ -163,7 +163,9 @@ CCreatureAnimation::CCreatureAnimation(std::string name, TSpeedController contro pixelDataSize = data.second; } - CBinaryReader reader(new CMemoryStream(pixelData.get(), pixelDataSize)); + CMemoryStream stm(pixelData.get(), pixelDataSize); + + CBinaryReader reader(&stm); reader.readInt32(); // def type, unused @@ -307,7 +309,9 @@ void CCreatureAnimation::nextFrameT(SDL_Surface * dest, bool rotate) ui32 offset = dataOffsets.at(type).at(floor(currentFrame)); - CBinaryReader reader(new CMemoryStream(pixelData.get(), pixelDataSize)); + CMemoryStream stm(pixelData.get(), pixelDataSize); + + CBinaryReader reader(&stm); reader.getStream()->seek(offset);