From de9e28700aede907622882b991fd830e929eb8f5 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 13 Jan 2026 05:43:59 +0500 Subject: [PATCH] engine: client: prevent a crash in case of invalid tempentity message (thanks, @Aynekko!) --- engine/client/cl_tent.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index c5f1d864..ce3beed1 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -2050,6 +2050,14 @@ void CL_ParseTempEntity( sizebuf_t *msg, connprotocol_t proto ) else entityIndex = 0; pEnt = CL_GetEntityByIndex( entityIndex ); + + // this might be obvious, but do not exit _before_ all data has been read or we will get parsing error later + if( !pEnt ) + { + Con_Reportf( "%s: ignored temp entity message %d, invalid entity num %d\n", __func__, type, entityIndex ); + break; + } + modelIndex = pEnt->curstate.modelindex; } CL_DecalShoot( CL_DecalIndex( decalIndex ), entityIndex, modelIndex, pos, type == TE_BSPDECAL ? FDECAL_PERMANENT : 0 );