From: Guus Sliepen Date: Tue, 21 Dec 2010 15:01:15 +0000 (+0100) Subject: Fix mismatched allocation and deallocation and memory leak in medal code. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b48b3a70005526dfb6481b3b22d50a891fb982e1;p=quix0rs-blobwars.git Fix mismatched allocation and deallocation and memory leak in medal code. Found by cppcheck. --- diff --git a/src/CMedalServer.cpp b/src/CMedalServer.cpp index 1ec4e79..a0ca88b 100644 --- a/src/CMedalServer.cpp +++ b/src/CMedalServer.cpp @@ -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);