From 47a8f081e96ca1e89df1e2933108ff5a1aabf004 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Feb 2024 13:17:35 +0100 Subject: [PATCH] set currenttex to null if it gets an invalid texture id --- src/hardware/hw_cache.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index b83dbfb1f..1e9d74705 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -566,10 +566,17 @@ void HWR_LoadTextures(size_t pnumtextures) GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore) { GLMapTexture_t *grtex; + + if (tex < 0 || tex >= (signed)gr_numtextures) + { #ifdef PARANOIA - if ((unsigned)tex >= gr_numtextures) - I_Error("HWR_GetTexture: tex >= numtextures\n"); + I_Error("HWR_GetTexture: Invalid texture ID %d", tex); +#else + HWR_SetCurrentTexture(NULL); + return NULL; #endif + } + grtex = &gr_textures[tex*2 + (encoremap && !noencore ? 0 : 1)]; if (!grtex->mipmap.data && !grtex->mipmap.downloaded)