From f1a421c9f696d33ef1b7aa6fe84a271a05556af8 Mon Sep 17 00:00:00 2001 From: Lucas Hosseini Date: Fri, 12 May 2023 13:52:41 +0200 Subject: [PATCH] Fix disassembly scroll history. (#3183) Avoid calling `erase()` when `topOffsetHistoryPos + 1 >= `topOffsetHistory.size()`. closes #3181 --- src/widgets/DisassemblyWidget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/widgets/DisassemblyWidget.cpp b/src/widgets/DisassemblyWidget.cpp index 4d3dbe2b..ebbbfa0d 100644 --- a/src/widgets/DisassemblyWidget.cpp +++ b/src/widgets/DisassemblyWidget.cpp @@ -665,8 +665,10 @@ void DisassemblyWidget::on_seekChanged(RVA offset, CutterCore::SeekHistoryType t { if (type == CutterCore::SeekHistoryType::New) { // Erase previous history past this point. - topOffsetHistory.erase(topOffsetHistory.begin() + topOffsetHistoryPos + 1, - topOffsetHistory.end()); + if (topOffsetHistory.size() > topOffsetHistoryPos + 1) { + topOffsetHistory.erase(topOffsetHistory.begin() + topOffsetHistoryPos + 1, + topOffsetHistory.end()); + } topOffsetHistory.push_back(offset); topOffsetHistoryPos = topOffsetHistory.size() - 1; } else if (type == CutterCore::SeekHistoryType::Undo) {