From ab5350977421dfc92bbbab8155efb5d2c0cec47a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 11 Apr 2019 13:26:10 +0300 Subject: [PATCH] - fixed crash in GLDEFS parser caused by missing texture https://forum.zdoom.org/viewtopic.php?t=64234 --- src/r_data/gldefs.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index be4645699..27bc58766 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -1266,26 +1266,29 @@ class GLDefsParser } } sc.MustGetString(); - bool okay = false; - for (int i = 0; i < MAX_CUSTOM_HW_SHADER_TEXTURES; i++) + if (tex) { - if (!tex->CustomShaderTextures[i]) + bool okay = false; + for (int i = 0; i < MAX_CUSTOM_HW_SHADER_TEXTURES; i++) { - tex->CustomShaderTextures[i] = TexMan.FindTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny); if (!tex->CustomShaderTextures[i]) { - sc.ScriptError("Custom hardware shader texture '%s' not found in texture '%s'\n", sc.String, tex ? tex->Name.GetChars() : "(null)"); - } + tex->CustomShaderTextures[i] = TexMan.FindTexture(sc.String, ETextureType::Any, FTextureManager::TEXMAN_TryAny); + if (!tex->CustomShaderTextures[i]) + { + sc.ScriptError("Custom hardware shader texture '%s' not found in texture '%s'\n", sc.String, tex->Name.GetChars()); + } - texNameList.Push(textureName); - texNameIndex.Push(i); - okay = true; - break; + texNameList.Push(textureName); + texNameIndex.Push(i); + okay = true; + break; + } + } + if (!okay) + { + sc.ScriptError("Error: out of texture units in texture '%s'", tex->Name.GetChars()); } - } - if (!okay) - { - sc.ScriptError("Error: out of texture units in texture '%s'", tex ? tex->Name.GetChars() : "(null)"); } } else if (sc.Compare("define"))