From f48b92eefd6bb41d5b86cb930661d062fb34efc8 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:25:13 -0700 Subject: [PATCH] memory: Guard against OrbisProcParam without an OrbisKernelMemParam. --- src/core/linker.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/linker.cpp b/src/core/linker.cpp index 37ac657da..9783ad96f 100644 --- a/src/core/linker.cpp +++ b/src/core/linker.cpp @@ -68,9 +68,17 @@ void Linker::Execute() { } // Configure used flexible memory size. - if (auto* mem_param = GetProcParam()->mem_param) { - if (u64* flexible_size = mem_param->flexible_memory_size) { - memory->SetupMemoryRegions(*flexible_size); + if (const auto* proc_param = GetProcParam()) { + if (proc_param->size >= + offsetof(OrbisProcParam, mem_param) + sizeof(OrbisKernelMemParam*)) { + if (const auto* mem_param = proc_param->mem_param) { + if (mem_param->size >= + offsetof(OrbisKernelMemParam, flexible_memory_size) + sizeof(u64*)) { + if (const auto* flexible_size = mem_param->flexible_memory_size) { + memory->SetupMemoryRegions(*flexible_size); + } + } + } } }