From 1c2f58fdcda20f8f7d2cb6e8ebcf64df5a01ed09 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Mon, 17 May 2021 23:49:53 +0300
Subject: SL-15185 Crash "The face does not have a valid texture"

---
 indra/newview/llviewertexture.cpp | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 20a22ba45e..f5c4192d36 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -3525,11 +3525,22 @@ BOOL LLViewerMediaTexture::findFaces()
 	for(; iter != obj_list->end(); ++iter)
 	{
 		LLVOVolume* obj = *iter;
-		if(obj->mDrawable.isNull())
-		{
-			ret = FALSE;
-			continue;
-		}
+        if (obj->isDead())
+        {
+            // Isn't supposed to happen, objects are supposed to detach
+            // themselves on markDead()
+            // If this happens, viewer is likely to crash
+            llassert(0);
+            LL_WARNS() << "Dead object in mMediaImplp's object list" << LL_ENDL;
+            ret = FALSE;
+            continue;
+        }
+
+        if (obj->mDrawable.isNull() || obj->mDrawable->isDead())
+        {
+            ret = FALSE;
+            continue;
+        }
 
 		S32 face_id = -1;
 		S32 num_faces = obj->mDrawable->getNumFaces();
-- 
cgit v1.2.3