瀏覽代碼

Fix issues found by Valgrind

Ivan Savenko 7 月之前
父節點
當前提交
6877bbfe3a
共有 3 個文件被更改,包括 13 次插入2 次删除
  1. 6 0
      client/media/CSoundHandler.cpp
  2. 6 1
      client/renderSDL/SDLImage.cpp
  3. 1 1
      lib/mapObjects/CGCreature.h

+ 6 - 0
client/media/CSoundHandler.cpp

@@ -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);
+		}
 	}
 }
 

+ 6 - 1
client/renderSDL/SDLImage.cpp

@@ -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;
 }
 

+ 1 - 1
lib/mapObjects/CGCreature.h

@@ -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