From 8e2ea5d84218e7c673275919be7c14f8da9c8331 Mon Sep 17 00:00:00 2001 From: Tobias Predel Date: Mon, 4 Nov 2024 21:55:06 +0100 Subject: [PATCH] Do not use invalid iterators (#749) --- src/document.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/document.h b/src/document.h index 8205e26d..80ed0efb 100644 --- a/src/document.h +++ b/src/document.h @@ -507,7 +507,8 @@ struct Document { if (drawroot->grid && drawroot->grid->folded) SetSelect(drawroot->parent->grid->FindCell(drawroot)); } - while (len < drawpath.size()) drawpath.erase(drawpath.begin()); + if (auto diff = drawpath.size() - len) + drawpath.erase(drawpath.begin(), drawpath.begin() + diff); } void Zoom(int dir, wxDC &dc, bool fromroot = false) {