From c4dc4928c8138f58fd4cdda9b4087aa5680c7d40 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 21 Oct 2020 03:01:09 -0400
Subject: [PATCH] Fix crash exposed by LLMutexLock::unlock...

---
 indra/llcommon/llmutex.h           | 1 +
 indra/newview/llmeshrepository.cpp | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/llcommon/llmutex.h b/indra/llcommon/llmutex.h
index a7bce83f5e8..4eab97e920b 100644
--- a/indra/llcommon/llmutex.h
+++ b/indra/llcommon/llmutex.h
@@ -96,6 +96,7 @@ class LLMutexLock
 	{
 		if (mMutex)
 			mMutex->unlock();
+		mMutex = nullptr;
 	}
 private:
 	LLMutex* mMutex;
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index f69df0a981f..1687cde50f4 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -1173,7 +1173,7 @@ void LLMeshRepoThread::lockAndLoadMeshLOD(const LLVolumeParams& mesh_params, S32
 
 void LLMeshRepoThread::loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod)
 { //could be called from any thread
-	std::unique_lock<LLMutex> header_lock(*mHeaderMutex);
+	LLMutexLock header_lock(mHeaderMutex);
 	mesh_header_map::iterator iter = mMeshHeader.find(mesh_params.getSculptID());
 	if (iter != mMeshHeader.end())
 	{ //if we have the header, request LOD byte range
-- 
GitLab