Fix disassembly scroll history. (#3183)

Avoid calling `erase()` when `topOffsetHistoryPos + 1 >=
`topOffsetHistory.size()`.

closes #3181
This commit is contained in:
Lucas Hosseini 2023-05-12 13:52:41 +02:00 committed by GitHub
parent 3e402c225e
commit f1a421c9f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {