From 620259ac0b5133a6c358c27fa22486d1720ec7e3 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Thu, 11 Jan 2024 22:05:34 -0500
Subject: [PATCH] Fix crash from audio engine init failures

---
 indra/llaudio/llaudioengine.cpp            | 2 ++
 indra/llaudio/llaudioengine_fmodstudio.cpp | 2 +-
 indra/newview/llviewermessage.cpp          | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp
index 05ce1f9829c..21e78518364 100644
--- a/indra/llaudio/llaudioengine.cpp
+++ b/indra/llaudio/llaudioengine.cpp
@@ -1951,6 +1951,8 @@ void LLAudioEngine::markSoundCorrupt(const LLUUID& sound_id)
 
 bool LLAudioEngine::isCorruptSound(const LLUUID& sound_id) const
 {
+	if (sound_id.isNull()) return true;
+
 	auto itr = mCorruptData.find(sound_id);
 	if (mCorruptData.end() == itr)
 		return false;
diff --git a/indra/llaudio/llaudioengine_fmodstudio.cpp b/indra/llaudio/llaudioengine_fmodstudio.cpp
index 075282051b0..db9d585f9b2 100644
--- a/indra/llaudio/llaudioengine_fmodstudio.cpp
+++ b/indra/llaudio/llaudioengine_fmodstudio.cpp
@@ -195,7 +195,7 @@ bool LLAudioEngine_FMODSTUDIO::init(void* userdata, const std::string &app_title
 
 	// initialize the FMOD engine
     result = mSystem->init(LL_MAX_AUDIO_CHANNELS + EXTRA_SOUND_CHANNELS, fmod_flags, 0);
-    if (Check_FMOD_Error(result, "Error initializing FMOD Studio with default settins, retrying with other format"))
+    if (Check_FMOD_Error(result, "Error initializing FMOD Studio with default settings, retrying with other format"))
     {
         result = mSystem->setSoftwareFormat(44100, FMOD_SPEAKERMODE_STEREO, 0/*- ignore*/);
         if (Check_FMOD_Error(result, "Error setting sotware format. Can't init."))
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 2f65b27e1c4..7644bb8540b 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4200,7 +4200,7 @@ void process_sound_trigger(LLMessageSystem *msg, void **)
 	LLVector3	pos_local;
 
 	msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_SoundID, sound_id);
-	if (gAudiop->isCorruptSound(sound_id))
+	if (gAudiop && gAudiop->isCorruptSound(sound_id))
 		return;
 
 	msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_OwnerID, owner_id);
-- 
GitLab