From c27e20703366ceb8a536c0a4ca22645500f426eb Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 6 Aug 2020 17:46:53 +0300 Subject: SL-13737 Crash when cleaning up uninitialized ndof device --- indra/newview/llappviewer.cpp | 7 +++++-- indra/newview/llviewerjoystick.cpp | 11 +++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index cf9ad7ccbf..75574df00e 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1851,8 +1851,11 @@ bool LLAppViewer::cleanup() delete gKeyboard; gKeyboard = NULL; - // Turn off Space Navigator and similar devices - LLViewerJoystick::getInstance()->terminate(); + if (LLViewerJoystick::instanceExists()) + { + // Turn off Space Navigator and similar devices + LLViewerJoystick::getInstance()->terminate(); + } LL_INFOS() << "Cleaning up Objects" << LL_ENDL; diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp index 3d06c95080..491ad7e3b2 100644 --- a/indra/newview/llviewerjoystick.cpp +++ b/indra/newview/llviewerjoystick.cpp @@ -309,10 +309,13 @@ void LLViewerJoystick::init(bool autoenable) void LLViewerJoystick::terminate() { #if LIB_NDOF - - ndof_libcleanup(); - LL_INFOS("joystick") << "Terminated connection with NDOF device." << LL_ENDL; - mDriverState = JDS_UNINITIALIZED; + if (mNdofDev != NULL) + { + ndof_libcleanup(); // frees alocated memory in mNdofDev + mDriverState = JDS_UNINITIALIZED; + mNdofDev = NULL; + LL_INFOS("joystick") << "Terminated connection with NDOF device." << LL_ENDL; + } #endif } -- cgit v1.2.3