From 4c667d9d8c264b03407a7d392af756ab8da5a8c3 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 17 May 2026 11:45:22 +0500 Subject: [PATCH] engine: client: bound current_position with HISTORY_MASK, in case of something passes invalid values --- engine/client/cl_frame.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/engine/client/cl_frame.c b/engine/client/cl_frame.c index 4943d711..133c871c 100644 --- a/engine/client/cl_frame.c +++ b/engine/client/cl_frame.c @@ -43,7 +43,7 @@ static void CL_UpdatePositions( cl_entity_t *ent ) { position_history_t *ph, *prev; - prev = &ent->ph[ent->current_position]; + prev = &ent->ph[ent->current_position & HISTORY_MASK]; ent->current_position = (ent->current_position + 1) & HISTORY_MASK; ph = &ent->ph[ent->current_position]; @@ -74,11 +74,10 @@ Interpolation init or reset after teleporting */ static void CL_ResetPositions( cl_entity_t *ent ) { - position_history_t store; + if( !ent ) + return; - if( !ent ) return; - - store = ent->ph[ent->current_position]; + position_history_t store = ent->ph[ent->current_position & HISTORY_MASK]; ent->current_position = 1; memset( ent->ph, 0, sizeof( position_history_t ) * HISTORY_MAX );