From 3a80df007eefaf8e7a85a313a0e5e97a3d7e0dd4 Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Wed, 26 Jun 2024 18:04:28 +0300 Subject: [PATCH] linker: More null check --- src/core/linker.cpp | 6 ++++-- src/core/memory.cpp | 12 +++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/core/linker.cpp b/src/core/linker.cpp index 1e1d4301..09526b53 100644 --- a/src/core/linker.cpp +++ b/src/core/linker.cpp @@ -68,8 +68,10 @@ void Linker::Execute() { } // Configure used flexible memory size. - if (u64* flexible_size = GetProcParam()->mem_param->flexible_memory_size) { - memory->SetTotalFlexibleSize(*flexible_size); + if (auto* mem_param = GetProcParam()->mem_param) { + if (u64* flexible_size = mem_param->flexible_memory_size) { + memory->SetTotalFlexibleSize(*flexible_size); + } } // Init primary thread. diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 58593fd7..9ebd1fea 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -206,9 +206,15 @@ int MemoryManager::QueryProtection(VAddr addr, void** start, void** end, u32* pr const auto& vma = it->second; ASSERT_MSG(vma.type != VMAType::Free, "Provided address is not mapped"); - *start = reinterpret_cast(vma.base); - *end = reinterpret_cast(vma.base + vma.size); - *prot = static_cast(vma.prot); + if (start != nullptr) { + *start = reinterpret_cast(vma.base); + } + if (end != nullptr) { + *end = reinterpret_cast(vma.base + vma.size); + } + if (prot != nullptr) { + *prot = static_cast(vma.prot); + } return ORBIS_OK; }