]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Fix mismatched allocation and deallocation and memory leak in medal code.
authorGuus Sliepen <guus@debian.org>
Tue, 21 Dec 2010 15:01:15 +0000 (16:01 +0100)
committerGuus Sliepen <guus@debian.org>
Tue, 21 Dec 2010 15:01:15 +0000 (16:01 +0100)
Found by cppcheck.

src/CMedalServer.cpp

index 1ec4e79ea8a60cb56e4cd77d98d0e511ca39686f..a0ca88b56caa9b6bdf174aecd136cb08f754e785 100644 (file)
@@ -90,7 +90,6 @@ int MedalServer::postMedal(const char *str)
                return 0;
        }
        
-       char *in = new char[1024];
        char out[1024];
        
        snprintf(out, sizeof out, "GET /addMedal/%s/MBS_%s HTTP/1.1\nHost: %s\nUser-Agent:BWMBS%.2f-%d\n\n", privateKey, medal, MEDAL_SERVER_HOST, VERSION, RELEASE);
@@ -108,6 +107,8 @@ int MedalServer::postMedal(const char *str)
                return 0;
        }
        
+       char *in = new char[1024];
+
        SDLNet_TCP_Recv(socket, in, 512);
        
        //printf("%s\n", in);
@@ -137,7 +138,7 @@ int MedalServer::postMedal(const char *str)
        
        debug(("MedalServer Response: %d '%s'\n", response, message))
        
-       delete in;
+       delete[] in;
        
        SDLNet_TCP_Close(socket);