From b574aba98b6714b9229a3b0fadf5aaf92851dd51 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Mon, 20 Jan 2025 16:06:08 +1000 Subject: [PATCH] service-am: Handle panic conditions in SetTerminateResult - Prevents propagation of panic conditions when setting termination results - Previously, panic error codes could trigger cascading crashes - Only stores non-error termination results while allowing successful completion - Fixes crash when applications set panic-related termination codes (0x1A80A) --- .../hle/service/am/service/application_functions.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp index 6fcda9165..30c2715a6 100644 --- a/src/core/hle/service/am/service/application_functions.cpp +++ b/src/core/hle/service/am/service/application_functions.cpp @@ -181,13 +181,16 @@ Result IApplicationFunctions::GetDesiredLanguage(Out out_language_code) { } Result IApplicationFunctions::SetTerminateResult(Result terminate_result) { - LOG_INFO(Service_AM, "(STUBBED) called, result={:#x} ({:04}-{:04})", + LOG_INFO(Service_AM, "called, result={:#x} ({:04}-{:04})", terminate_result.GetInnerValue(), static_cast(terminate_result.GetModule()) + 2000, terminate_result.GetDescription()); - std::scoped_lock lk{m_applet->lock}; - m_applet->terminate_result = terminate_result; + // Only set the terminate result if it's not a panic + if (!terminate_result.IsError()) { + std::scoped_lock lk{m_applet->lock}; + m_applet->terminate_result = terminate_result; + } R_SUCCEED(); }