From: Guus Sliepen Date: Sat, 3 Jul 2010 18:28:29 +0000 (+0200) Subject: Various fixes for bugs valgrind found. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=526c66b62ed66bc9845422b15053e6b5586a501d;p=quix0rs-blobwars.git Various fixes for bugs valgrind found. --- diff --git a/src/CEngine.cpp b/src/CEngine.cpp index 37238ae..2520ba1 100644 --- a/src/CEngine.cpp +++ b/src/CEngine.cpp @@ -426,9 +426,10 @@ bool Engine::loadData(const char *filename) rewind(fp); - dataBuffer = new unsigned char[fSize]; + dataBuffer = new unsigned char[fSize + 1]; fread(dataBuffer, 1, fSize, fp); + dataBuffer[fSize] = 0; fclose(fp); diff --git a/src/CGraphics.cpp b/src/CGraphics.cpp index f69dcc4..5c3071e 100644 --- a/src/CGraphics.cpp +++ b/src/CGraphics.cpp @@ -963,10 +963,10 @@ void Graphics::drawChatString(SDL_Surface *surface, int y) blit(wordSurface, x, y, surface, false); - SDL_FreeSurface(wordSurface); - x += wordSurface->w; + SDL_FreeSurface(wordSurface); + word = strtok(NULL, " "); } } diff --git a/src/bosses.cpp b/src/bosses.cpp index 609b23f..bcae266 100644 --- a/src/bosses.cpp +++ b/src/bosses.cpp @@ -398,11 +398,12 @@ void doBosses() { debug(("Deleting unreferenced Boss...\n")); + if(map.mainBossPart == map.boss[i]) + map.mainBossPart = NULL; delete map.boss[i]; map.boss[i] = NULL; - } - - self->referenced = false; + } else + self->referenced = false; } } else if (self->actionFinished()) diff --git a/src/cutscene.cpp b/src/cutscene.cpp index 1def602..3d49d76 100644 --- a/src/cutscene.cpp +++ b/src/cutscene.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void createSceneList() { - char sceneLine[1024]; + char sceneLine[1024] = ""; char *line = NULL; int waitTime = 0; Cutscene *scene = NULL; diff --git a/src/player.cpp b/src/player.cpp index 77661d8..151b07c 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -56,7 +56,7 @@ int medalWorker(void *data) SDL_mutexV(medalServer.lock); - delete tname; + delete[] tname; return type; }