1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

Fix issues found by Valgrind

This commit is contained in:
Ivan Savenko
2025-03-12 15:56:52 +00:00
parent 96d691b40c
commit 6877bbfe3a
3 changed files with 13 additions and 2 deletions

View File

@ -64,6 +64,12 @@ CSoundHandler::~CSoundHandler()
if(chunk.second.first)
Mix_FreeChunk(chunk.second.first);
}
for(auto & chunk : soundChunksRaw)
{
if(chunk.second.first)
Mix_FreeChunk(chunk.second.first);
}
}
}

View File

@ -24,7 +24,6 @@
#include "../../lib/CConfigHandler.h"
#include <tbb/parallel_for.h>
#include <tbb/task_arena.h>
#include <SDL_image.h>
#include <SDL_surface.h>
@ -400,6 +399,9 @@ std::shared_ptr<const ISharedImage> SDLImageShared::horizontalFlip() const
ret->margins.y = fullSize.y - surf->h - margins.y;
ret->fullSize = fullSize;
// erase our own reference
SDL_FreeSurface(flipped);
return ret;
}
@ -418,6 +420,9 @@ std::shared_ptr<const ISharedImage> SDLImageShared::verticalFlip() const
ret->margins.y = margins.y;
ret->fullSize = fullSize;
// erase our own reference
SDL_FreeSurface(flipped);
return ret;
}

View File

@ -27,7 +27,7 @@ public:
COMPLIANT = 0, FRIENDLY = 1, AGGRESSIVE = 2, HOSTILE = 3, SAVAGE = 4
};
ui32 identifier; //unique code for this monster (used in missions)
ui32 identifier = -1; //unique code for this monster (used in missions)
si8 character = 0; //character of this set of creatures (0 - the most friendly, 4 - the most hostile) => on init changed to -4 (compliant) ... 10 value (savage)
MetaString message; //message printed for attacking hero
TResources resources; // resources given to hero that has won with monsters