mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-03 11:13:44 +01:00
OSK: Fix a use-after-free when loading a savestate
DoState replaced native_ while holding a lock_guard on its mutex, so the old NativeInput could be freed before the guard unlocked it. Crashed every state load (e.g. Splinter Cell Essentials, anywhere in the game). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
547d032995
commit
797957ea25
1 file changed
+4
-2
@@ -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<std::mutex> 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<NativeInput> native = native_;
|
||||
std::lock_guard<std::mutex> guard(native->mutex);
|
||||
if (native->status != PSPOskNativeStatus::WAITING) {
|
||||
native_ = std::make_shared<NativeInput>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user