diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 8e0ab56a30..f19bd41faf 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -1099,8 +1099,10 @@ void PSPOskDialog::DoState(PointerWrap &p) if (p.mode == p.MODE_READ) { // A box still open can answer into the loaded state (the next Update would only open // another). One that finished before mustn't block the next. - std::lock_guard guard(native_->mutex); - if (native_->status != PSPOskNativeStatus::WAITING) { + // Hold a reference, so the guard doesn't outlive the mutex it unlocks when native_ is replaced. + std::shared_ptr native = native_; + std::lock_guard guard(native->mutex); + if (native->status != PSPOskNativeStatus::WAITING) { native_ = std::make_shared(); } }