From 14765bf64bf97d21baff8cb82a63125a254e406c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 21 Jun 2006 15:40:42 +0000 Subject: [PATCH] - Fixed: The sidedef loader could allocate insufficient memory if a map contained unused sidedefs. - Fixed: Color control sequences were written to the log file. Since any entered console command contains such a sequence it was quite noticable. SVN r208 (trunk) --- docs/rh-log.txt | 4 ++++ src/c_console.cpp | 22 +++++++++++++++++++++- src/p_setup.cpp | 5 ++--- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 31ca6debee..9012a4cd1b 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,8 @@ June 21, 2006 (Changes by Graf Zahl) +- Fixed: The sidedef loader could allocate insufficient memory if a map + contained unused sidedefs. +- Fixed: Color control sequences were written to the log file. Since any + entered console command contains such a sequence it was quite noticable. - Fixed: The obituary code didn't use the attacker's name for kills caused by other players. - Fixed: PIT_StompThing never checked for COMPATF_NO_PASSMOBJ. diff --git a/src/c_console.cpp b/src/c_console.cpp index 3431264c1f..18463d4f18 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -811,7 +811,27 @@ int PrintString (int printlevel, const char *outline) if (Logfile) { - fputs (outline, Logfile); + // Strip out any color escape sequences before writing to the log file + char * copy = new char[strlen(outline)+1]; + const char * srcp = outline; + char * dstp = copy; + + while (*srcp != 0) + { + if (*srcp!=0x1c) + { + *dstp++=*srcp++; + } + else + { + if (srcp[1]!=0) srcp+=2; + else break; + } + } + *dstp=0; + + fputs (copy, Logfile); + delete [] copy; //#ifdef _DEBUG fflush (Logfile); //#endif diff --git a/src/p_setup.cpp b/src/p_setup.cpp index bb96ec9e1b..7b47d6c42d 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -2083,15 +2083,14 @@ void P_LoadSideDefs2 (MapData * map) { int i; char name[9]; - mapsidedef_t * msdf = new mapsidedef_t[numsides+1]; - + char * msdf = new char[map->Size(ML_SIDEDEFS)]; map->Read(ML_SIDEDEFS, msdf); name[8] = 0; for (i = 0; i < numsides; i++) { - mapsidedef_t *msd = msdf + sidetemp[i].a.map; + mapsidedef_t *msd = ((mapsidedef_t*)msdf) + sidetemp[i].a.map; side_t *sd = sides + i; sector_t *sec;