Skip to content

Commit

Permalink
Prevent out of bound writes if a shader has too many stages.
Browse files Browse the repository at this point in the history
Display the same warning ioq3 and OpenJK display, but don't mark the shader as invalid to prevent it from showing as missing shader for existing maps.
  • Loading branch information
Daggolin committed May 19, 2023
1 parent 088774a commit 5d19251
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/renderer/tr_shader.cpp
Expand Up @@ -2157,6 +2157,12 @@ static qboolean ParseShader( const char **text )
// stage definition
else if ( token[0] == '{' )
{
if ( s >= MAX_SHADER_STAGES )
{
ri.Printf( PRINT_WARNING, "WARNING: too many stages in shader %s (max is %i)\n", shader.name, MAX_SHADER_STAGES );
break; // Don't return with qfalse, because we don't want existing shaders violating MAX_SHADER_STAGES to be displayed as missing shaders
}

if ( !ParseStage( &stages[s], text ) )
{
return qfalse;
Expand Down

0 comments on commit 5d19251

Please sign in to comment.