From 720e05d131f7d309e236240ca6b62b2ca16b03a4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Feb 2017 02:31:19 +0100 Subject: [PATCH] - fixed memory leak in DEM_NETEVENT. - added handling for DEM_NETEVENT to SkipCommand. - keep the data of DEM_NETEVENT at a fixed length to simplify handling. --- src/d_net.cpp | 9 +++++++-- src/events.cpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index fb7cac316..10ff7d0fc 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2666,12 +2666,13 @@ void Net_DoCommand (int type, BYTE **stream, int player) case DEM_NETEVENT: { - FString ename = ReadString(stream); + const char *ename = ReadString(stream); int argn = ReadByte(stream); int arg[3] = { 0, 0, 0 }; - for (int i = 0; i < argn; i++) + for (int i = 0; i < 3; i++) arg[i] = ReadLong(stream); E_Console(player, ename, arg[0], arg[1], arg[2]); + delete[] ename; } break; @@ -2721,6 +2722,10 @@ void Net_SkipCommand (int type, BYTE **stream) skip = strlen ((char *)(*stream)) + 5; break; + case DEM_NETEVENT: + skip = strlen((char *)(*stream)) + 13; + break; + case DEM_SUMMON2: case DEM_SUMMONFRIEND2: case DEM_SUMMONFOE2: diff --git a/src/events.cpp b/src/events.cpp index d714eefce..a0780fb92 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -1139,7 +1139,7 @@ CCMD(netevent) Net_WriteByte(DEM_NETEVENT); Net_WriteString(argv[1]); Net_WriteByte(argn); - for (int i = 0; i < argn; i++) + for (int i = 0; i < 3; i++) Net_WriteLong(arg[i]); } }