From 769372e2f9e384b73f4f1882ddb888857ed3c1e8 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Thu, 20 Oct 2005 16:14:05 +0000 Subject: [PATCH] * Fix to buffer overflow in lightmap loading code from misanthropia --- code/renderer/tr_bsp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/renderer/tr_bsp.c b/code/renderer/tr_bsp.c index 217a3d8b..f6e9691e 100644 --- a/code/renderer/tr_bsp.c +++ b/code/renderer/tr_bsp.c @@ -140,7 +140,7 @@ static void R_LoadLightmaps( lump_t *l ) { float maxIntensity = 0; double sumIntensity = 0; - len = l->filelen; + len = l->filelen; if ( !len ) { return; } @@ -155,6 +155,9 @@ static void R_LoadLightmaps( lump_t *l ) { //FIXME: HACK: maps with only one lightmap turn up fullbright for some reason. //this avoids this, but isn't the correct solution. tr.numLightmaps++; + } else if ( tr.numLightmaps >= MAX_LIGHTMAPS ) { // 20051020 misantropia + ri.Printf( PRINT_WARNING, "WARNING: number of lightmaps > MAX_LIGHTMAPS\n" ); + tr.numLightmaps = MAX_LIGHTMAPS; } // if we are in r_vertexLight mode, we don't need the lightmaps at all