From 2c2b19bb7f508dbf0353cfd8843fab27d666a949 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 10 May 2018 18:01:29 +0300 Subject: [PATCH] - fixed crash during autoloading of material textures https://forum.zdoom.org/viewtopic.php?t=60546 --- src/textures/texturemanager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index d266a7a01..b922d8bb5 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -1050,9 +1050,12 @@ void FTextureManager::Init() InitPalettedVersions(); AdjustSpriteOffsets(); // Add auto materials to each texture after everything has been set up. - for (auto &tex : Textures) + // Textures array can be reallocated in process, so ranged for loop is not suitable. + // There is no need to process discovered material textures here, + // CheckForTexture() did this already. + for (unsigned int i = 0, count = Textures.Size(); i < count; ++i) { - tex.Texture->AddAutoMaterials(); + Textures[i].Texture->AddAutoMaterials(); } glLight = TexMan.CheckForTexture("glstuff/gllight.png", ETextureType::MiscPatch);