From 1f17a3bb1e1d5e150432c1cb4bbd8cccf12b989b Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Fri, 29 Jul 2022 18:27:50 -0700 Subject: [PATCH] PPCSymbolDB: Fix getting symbol for the last function --- Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index d684cf64da..e69f6591e2 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -92,18 +92,20 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam Common::Symbol* PPCSymbolDB::GetSymbolFromAddr(u32 addr) { auto it = m_functions.lower_bound(addr); - if (it == m_functions.end()) - return nullptr; - // If the address is exactly the start address of a symbol, we're done. - if (it->second.address == addr) - return &it->second; - - // Otherwise, check whether the address is within the bounds of a symbol. + if (it != m_functions.end()) + { + // If the address is exactly the start address of a symbol, we're done. + if (it->second.address == addr) + return &it->second; + } if (it != m_functions.begin()) + { + // Otherwise, check whether the address is within the bounds of a symbol. --it; - if (addr >= it->second.address && addr < it->second.address + it->second.size) - return &it->second; + if (addr >= it->second.address && addr < it->second.address + it->second.size) + return &it->second; + } return nullptr; }