From b2241e3feffae3a666d822724b1f49365b137d0d Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Mon, 6 Jul 2015 19:19:32 -0500 Subject: [PATCH] Avoid calling OnUnload twice. --- src/xenia/kernel/objects/xuser_module.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/xenia/kernel/objects/xuser_module.cc b/src/xenia/kernel/objects/xuser_module.cc index 9209c2172..037611d37 100644 --- a/src/xenia/kernel/objects/xuser_module.cc +++ b/src/xenia/kernel/objects/xuser_module.cc @@ -112,12 +112,17 @@ X_STATUS XUserModule::LoadFromMemory(const void* addr, const size_t length) { } X_STATUS XUserModule::Unload() { - if (!xex_module()->Unload()) { - return X_STATUS_UNSUCCESSFUL; + if (!xex_module()->loaded()) { + // Quick abort. + return X_STATUS_SUCCESS; } - OnUnload(); - return X_STATUS_SUCCESS; + if (xex_module()->Unload()) { + OnUnload(); + return X_STATUS_SUCCESS; + } + + return X_STATUS_UNSUCCESSFUL; } uint32_t XUserModule::GetProcAddressByOrdinal(uint16_t ordinal) {