From d84df6e47f5338f0d0cff36bb08c4d27d6c442b4 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Sat, 21 Oct 2023 10:12:48 +0200 Subject: [PATCH] [Memory] Added check to prevent crashes when title tries to get access to unavailable range --- src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc index 8cc80bc8f..6ff1e5281 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc @@ -108,6 +108,13 @@ dword_result_t NtAllocateVirtualMemory_entry(lpdword_t base_addr_ptr, if (*base_addr_ptr != 0) { // ignore specified page size when base address is specified. auto heap = kernel_memory()->LookupHeap(*base_addr_ptr); + // Edge case when title can check for XPS/MMIO range and will receive + // nullptr. + if (!heap) { + // Code returned in this case is unknown but probably this one. + return X_STATUS_INVALID_PARAMETER; + } + if (heap->heap_type() != HeapType::kGuestVirtual) { return X_STATUS_INVALID_PARAMETER; }