From 1b111f031341ab6f4441efe914767b774eb8da25 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Mon, 4 May 2015 22:16:48 -0500 Subject: [PATCH] Thread safety --- src/xenia/kernel/kernel_state.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/xenia/kernel/kernel_state.cc b/src/xenia/kernel/kernel_state.cc index 3472efdec..151f862e7 100644 --- a/src/xenia/kernel/kernel_state.cc +++ b/src/xenia/kernel/kernel_state.cc @@ -111,6 +111,8 @@ XModule* KernelState::GetModule(const char* name) { // Some games request this, for some reason. wtf. return nullptr; } else { + std::lock_guard lock(object_mutex_); + for (XUserModule *module : user_modules_) { if (module->name() == name) { module->Retain(); @@ -146,6 +148,8 @@ void KernelState::SetExecutableModule(XUserModule* module) { } XUserModule* KernelState::LoadUserModule(const char *name) { + std::lock_guard lock(object_mutex_); + // See if we've already loaded it for (XUserModule *module : user_modules_) { if (module->name() == name) { @@ -158,7 +162,7 @@ XUserModule* KernelState::LoadUserModule(const char *name) { XUserModule *module = new XUserModule(this, name); X_STATUS status = module->LoadFromFile(name); if (XFAILED(status)) { - delete module; + module->Release(); return nullptr; }