]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Various fixes for bugs valgrind found.
authorGuus Sliepen <guus@debian.org>
Sat, 3 Jul 2010 18:28:29 +0000 (20:28 +0200)
committerGuus Sliepen <guus@debian.org>
Sat, 3 Jul 2010 18:28:29 +0000 (20:28 +0200)
src/CEngine.cpp
src/CGraphics.cpp
src/bosses.cpp
src/cutscene.cpp
src/player.cpp

index 37238ae89a50b5a69ad44d1b142fa41017909c54..2520ba1d58cdae2c415acca4ac58e67379c232d6 100644 (file)
@@ -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);
 
index f69dcc4108c58a1c2867a1e26a1413abad2ddd86..5c3071e381c22df784b1760960c5bbda99998c4a 100644 (file)
@@ -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, " ");
        }
 }
index 609b23faa62c66296d736f9413a994b3ce96b3e0..bcae2662555006181b8f6405cab144c1fc181d36 100644 (file)
@@ -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())
index 1def602ed00b1b16ade030c2a416dd81b1a8e4e9..3d49d767384f78260d8e5942ac00f93b5476d45e 100644 (file)
@@ -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;
index 77661d8096cfa1787637faab72a20e6cd97f8df5..151b07cc7d4ffcad3d6b1104b0f3ae863cec03f8 100644 (file)
@@ -56,7 +56,7 @@ int medalWorker(void *data)
        
        SDL_mutexV(medalServer.lock);
        
-       delete tname;
+       delete[] tname;
        
        return type;
 }