diff --git a/code/renderer/tr_shader.c b/code/renderer/tr_shader.c index f896f31a..7e9a37ef 100644 --- a/code/renderer/tr_shader.c +++ b/code/renderer/tr_shader.c @@ -1432,6 +1432,12 @@ static qboolean ParseShader( char **text ) // stage definition else if ( token[0] == '{' ) { + // 20051019 misantropia -- fix buffer overrun. + if ( s >= MAX_SHADER_STAGES ) { + ri.Printf( PRINT_WARNING, "WARNING: too many stages in shader %s\n", shader.name ); + return qfalse; + } + if ( !ParseStage( &stages[s], text ) ) { return qfalse; @@ -1439,12 +1445,6 @@ static qboolean ParseShader( char **text ) stages[s].active = qtrue; s++; - // 20051019 misantropia -- fix buffer overrun. - if ( s >= MAX_SHADER_STAGES ) { - ri.Printf( PRINT_WARNING, "WARNING: too many stages in shader %s\n", shader.name ); - return qfalse; - } - continue; } // skip stuff that only the QuakeEdRadient needs