From 7de1de62b9d68a44d9dce89a57b8083d970ee5c6 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 11 Aug 2021 05:01:52 -0400
Subject: [PATCH] Fix crash from LLPointer falling out of scope

---
 indra/newview/llmaterialmgr.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp
index 671444cd689..6599ddc2bb8 100644
--- a/indra/newview/llmaterialmgr.cpp
+++ b/indra/newview/llmaterialmgr.cpp
@@ -394,11 +394,13 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL
 		itMaterial = ret.first;
 	}
 
-	setMaterialCallbacks(material_id, itMaterial->second);
+    LLMaterialPtr material_ptr = itMaterial->second;
+    
+	setMaterialCallbacks(material_id, material_ptr);
 
 	mGetPending.erase(pending_material_t(region_id, material_id));
 
-	return itMaterial->second;
+	return material_ptr;
 }
 
 void LLMaterialMgr::setMaterialCallbacks(const LLMaterialID& material_id, const LLMaterialPtr material_ptr)
-- 
GitLab