2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-25 11:19:59 +01:00

ref: fix some possible off by one errors

This commit is contained in:
Alibek Omarov 2024-11-17 13:05:15 +03:00
parent 8fd5a5af96
commit 046b1da8a8
5 changed files with 6 additions and 6 deletions

View File

@ -229,7 +229,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
VectorAdd( verts[0], delta, verts[2] ); VectorAdd( verts[0], delta, verts[2] );
VectorAdd( verts[1], delta, verts[3] ); VectorAdd( verts[1], delta, verts[3] );
if( p->color < 0 || p->color > sizeof( gTracerColors ) / sizeof( gTracerColors[0] )) if( p->color < 0 || p->color >= sizeof( gTracerColors ) / sizeof( gTracerColors[0] ))
{ {
p->color = TRACER_COLORINDEX_DEFAULT; p->color = TRACER_COLORINDEX_DEFAULT;
} }

View File

@ -245,7 +245,7 @@ int TriSpriteTexture( model_t *pSpriteModel, int frame )
if(( gl_texturenum = R_GetSpriteTexture( pSpriteModel, frame )) == 0 ) if(( gl_texturenum = R_GetSpriteTexture( pSpriteModel, frame )) == 0 )
return 0; return 0;
if( gl_texturenum <= 0 || gl_texturenum > MAX_TEXTURES ) if( gl_texturenum <= 0 || gl_texturenum >= MAX_TEXTURES )
gl_texturenum = tr.defaultTexture; gl_texturenum = tr.defaultTexture;
GL_Bind( XASH_TEXTURE0, gl_texturenum ); GL_Bind( XASH_TEXTURE0, gl_texturenum );

View File

@ -240,7 +240,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers
VectorAdd( verts[0], delta, verts[2] ); VectorAdd( verts[0], delta, verts[2] );
VectorAdd( verts[1], delta, verts[3] ); VectorAdd( verts[1], delta, verts[3] );
if( p->color < 0 || p->color > sizeof( gTracerColors ) / sizeof( gTracerColors[0] )) if( p->color < 0 || p->color >= sizeof( gTracerColors ) / sizeof( gTracerColors[0] ))
{ {
p->color = TRACER_COLORINDEX_DEFAULT; p->color = TRACER_COLORINDEX_DEFAULT;
} }

View File

@ -224,7 +224,7 @@ static void R_EmitEdge( mvertex_t *pv0, mvertex_t *pv1 )
v = ceilv0; v = ceilv0;
v2 = r_ceilv1 - 1; v2 = r_ceilv1 - 1;
if( v < 0 || v > MAXHEIGHT ) if( v < 0 || v >= MAXHEIGHT )
{ {
gEngfuncs.Con_Printf( S_ERROR "trailing edge overflow : %d\n", v ); gEngfuncs.Con_Printf( S_ERROR "trailing edge overflow : %d\n", v );
return; return;
@ -242,7 +242,7 @@ static void R_EmitEdge( mvertex_t *pv0, mvertex_t *pv1 )
v2 = ceilv0 - 1; v2 = ceilv0 - 1;
v = r_ceilv1; v = r_ceilv1;
if( v < 0 || v > MAXHEIGHT ) if( v < 0 || v >= MAXHEIGHT )
{ {
gEngfuncs.Con_Printf( S_ERROR "leading edge overflow : %d\n", v ); gEngfuncs.Con_Printf( S_ERROR "leading edge overflow : %d\n", v );
return; return;

View File

@ -289,7 +289,7 @@ int TriSpriteTexture( model_t *pSpriteModel, int frame )
if(( gl_texturenum = R_GetSpriteTexture( pSpriteModel, frame )) == 0 ) if(( gl_texturenum = R_GetSpriteTexture( pSpriteModel, frame )) == 0 )
return 0; return 0;
if( gl_texturenum <= 0 || gl_texturenum > MAX_TEXTURES ) if( gl_texturenum <= 0 || gl_texturenum >= MAX_TEXTURES )
gl_texturenum = tr.defaultTexture; gl_texturenum = tr.defaultTexture;
GL_Bind( XASH_TEXTURE0, gl_texturenum ); GL_Bind( XASH_TEXTURE0, gl_texturenum );