From 801bed23c45968271b14ca83f54e18d540714db4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 28 Nov 2025 16:49:13 +0100 Subject: [PATCH] OpenGL: add a little more checks during texture free prob not necessary but feels better --- src/hardware/hw_cache.c | 12 ++++++++++-- src/hardware/r_opengl/r_opengl.c | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index a24883911..2f4859af6 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -580,6 +580,9 @@ void HWR_InitMapTextures(void) static void FreeMapTexture(GLMapTexture_t *tex) { + if (!tex) + return; + GL_DeleteTexture(&tex->mipmap); Z_Free(tex->mipmap.data); tex->mipmap.data = NULL; @@ -589,6 +592,12 @@ void HWR_FreeMapTextures(void) { size_t i; + if (!gl_textures) + { + gl_numtextures = 0; + return; + } + for (i = 0; i < gl_numtextures; i++) { FreeMapTexture(&gl_textures[i].normal); @@ -599,8 +608,7 @@ void HWR_FreeMapTextures(void) // now the heap don't have any 'user' pointing to our // texturecache info, we can free it - if (gl_textures) - free(gl_textures); + free(gl_textures); gl_textures = NULL; gl_numtextures = 0; } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index e2495bcb9..72ff3881a 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1365,7 +1365,8 @@ void GL_Flush(void) TexCacheTail = TexCacheHead = NULL; //Hurdler: well, TexCacheHead is already NULL tex_downloaded = 0; - free(textureBuffer); + if (textureBuffer) + free(textureBuffer); textureBuffer = NULL; textureBufferSize = 0; } @@ -3320,8 +3321,8 @@ void GL_Framebuffer_Disable(void) // delet our fbo if (framebufferobject.fboobj) pglDeleteFramebuffers(1, &framebufferobject.fboobj); - framebufferobject.fboobj = 0; + GL_Framebuffer_DeleteAttachments(); } #endif