From 606d72adf2b94a5ec5563cee01c7b472461b3261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6ppe?= Date: Mon, 8 Jan 2018 15:17:58 +0000 Subject: [PATCH 1/2] [q3map2] Fix errnoneous plane access if plane was not found --- tools/quake3/q3map2/map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/quake3/q3map2/map.c b/tools/quake3/q3map2/map.c index 9b123626..861ca8ef 100644 --- a/tools/quake3/q3map2/map.c +++ b/tools/quake3/q3map2/map.c @@ -1086,7 +1086,7 @@ static void ParseRawBrush( qboolean onlyLights ){ side->planenum = planenum; /* bp: get the texture mapping for this texturedef / plane combination */ - if ( g_bBrushPrimit == BPRIMIT_OLDBRUSHES ) { + if ( g_bBrushPrimit == BPRIMIT_OLDBRUSHES && planenum != -1 ) { QuakeTextureVecs( &mapplanes[ planenum ], shift, rotate, scale, side->vecs ); } } From 760623150ed5683d43d8ffbed148fb9d9dca5d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6ppe?= Date: Mon, 8 Jan 2018 15:18:29 +0000 Subject: [PATCH 2/2] [q3map2] Unwind script stack in case of script loading error. Also avoid type punning read into char* variable (even though char* and void* happen to be layout-compatible). --- tools/quake3/common/scriplib.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/quake3/common/scriplib.c b/tools/quake3/common/scriplib.c index acd8d5ad..d0e533cb 100644 --- a/tools/quake3/common/scriplib.c +++ b/tools/quake3/common/scriplib.c @@ -58,6 +58,7 @@ qboolean tokenready; // only qtrue if UnGetToken was just ca */ void AddScriptToStack( const char *filename, int index ){ int size; + void* buffer; script++; if ( script == &scriptstack[MAX_INCLUDES] ) { @@ -65,10 +66,11 @@ void AddScriptToStack( const char *filename, int index ){ } strcpy( script->filename, ExpandPath( filename ) ); - size = vfsLoadFile( script->filename, (void **)&script->buffer, index ); + size = vfsLoadFile( script->filename, &buffer, index ); if ( size == -1 ) { Sys_Printf( "Script file %s was not found\n", script->filename ); + script--; } else { @@ -78,11 +80,12 @@ void AddScriptToStack( const char *filename, int index ){ else{ Sys_Printf( "entering %s\n", script->filename ); } - } - script->line = 1; - script->script_p = script->buffer; - script->end_p = script->buffer + size; + script->buffer = buffer; + script->line = 1; + script->script_p = script->buffer; + script->end_p = script->buffer + size; + } }