From 2f1389233e1eefbecf7703177b6f28248fcedc87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 13 Dec 2023 21:53:16 +0100 Subject: [PATCH 1/2] MemBlockInfo: Fix potential out-of-bounds in the slab map, reported by Nemoumbra --- Core/Debugger/MemBlockInfo.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/Debugger/MemBlockInfo.cpp b/Core/Debugger/MemBlockInfo.cpp index f727d3a484bf..0f6be382bf13 100644 --- a/Core/Debugger/MemBlockInfo.cpp +++ b/Core/Debugger/MemBlockInfo.cpp @@ -288,7 +288,12 @@ void MemSlabMap::Clear() { MemSlabMap::Slab *MemSlabMap::FindSlab(uint32_t addr) { // Jump ahead using our index. - Slab *slab = heads_[addr / SLICE_SIZE]; + size_t slabIndex = addr / SLICE_SIZE; + if (slabIndex >= heads_.size()) { + // Shouldn't happen, but apparently can. + return nullptr; + } + Slab *slab = heads_[slabIndex]; // We often move forward, so check the last find. if (lastFind_->start > slab->start && lastFind_->start <= addr) slab = lastFind_; From 15c0bb1bd06b5ab101dc4e87eda2dbc85651a9dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 13 Dec 2023 22:00:55 +0100 Subject: [PATCH 2/2] Fix crash in debugger after unloading the game. --- Windows/Debugger/Debugger_Lists.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Windows/Debugger/Debugger_Lists.cpp b/Windows/Debugger/Debugger_Lists.cpp index 8e65ea2770a3..c5f2a67b51b1 100644 --- a/Windows/Debugger/Debugger_Lists.cpp +++ b/Windows/Debugger/Debugger_Lists.cpp @@ -672,7 +672,9 @@ bool CtrlStackTraceView::WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, L void CtrlStackTraceView::GetColumnText(wchar_t* dest, int row, int col) { - if (row < 0 || row >= (int)frames.size()) { + // We should have emptied the list if g_symbolMap is nullptr, but apparently we don't, + // so let's have a sanity check here. + if (row < 0 || row >= (int)frames.size() || !g_symbolMap) { return; }