From a5cec06135be8415545765785a45227839ef2018 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sat, 20 Nov 2021 00:45:14 -0800 Subject: [PATCH] Kernel: Handle string format error in page_fault_handler(..) :^) Utilize the new KString::formatted to provide a fallback if formatting fails because of OOM or whatever reason. --- Kernel/Arch/x86/common/Interrupts.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Kernel/Arch/x86/common/Interrupts.cpp b/Kernel/Arch/x86/common/Interrupts.cpp index d5ddc1d2a6..64e41af52f 100644 --- a/Kernel/Arch/x86/common/Interrupts.cpp +++ b/Kernel/Arch/x86/common/Interrupts.cpp @@ -403,7 +403,9 @@ void page_fault_handler(TrapFrame* trap) if (current_thread) { auto& current_process = current_thread->process(); if (current_process.is_user_process()) { - (void)current_process.try_set_coredump_property("fault_address"sv, String::formatted("{:p}", fault_address)); + auto fault_address_string = KString::formatted("{:p}", fault_address); + auto fault_address_view = fault_address_string.is_error() ? ""sv : fault_address_string.value()->view(); + (void)current_process.try_set_coredump_property("fault_address"sv, fault_address_view); (void)current_process.try_set_coredump_property("fault_type"sv, fault.type() == PageFault::Type::PageNotPresent ? "NotPresent"sv : "ProtectionViolation"sv); StringView fault_access; if (fault.is_instruction_fetch())