diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp index 1694a36a32..214ac623ff 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp @@ -5405,9 +5405,19 @@ void Drawable::xfer(Xfer* xfer) { if (!customizedToSilence) { - AsciiString baseInfoName = m_customSoundAmbientInfo->getOriginalName(); - xfer->xferAsciiString(&baseInfoName); - m_customSoundAmbientInfo->xferNoName(xfer); + // Guard against dangling or invalid pointer before dereferencing + if (m_customSoundAmbientInfo != NULL) + { + AsciiString baseInfoName = m_customSoundAmbientInfo->getOriginalName(); + xfer->xferAsciiString(&baseInfoName); + m_customSoundAmbientInfo->xferNoName(xfer); + } + else + { + DEBUG_CRASH(("Drawable::xfer - m_customSoundAmbientInfo is NULL during save but customized flag is set; skipping custom ambient sound save")); + AsciiString emptyName; + xfer->xferAsciiString(&emptyName); + } } } }