From a81933131c62173108af44f5ad3fe433c3a07fa8 Mon Sep 17 00:00:00 2001 From: Brenton Bostick Date: Tue, 29 Oct 2024 08:00:00 -0400 Subject: [PATCH] fix using invalidated iterator --- lib/tablature.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/tablature.cpp b/lib/tablature.cpp index c026f32..f1f9d73 100644 --- a/lib/tablature.cpp +++ b/lib/tablature.cpp @@ -1008,10 +1008,15 @@ TtbtFileTablature(const tbt_file_t &t) { barLineWidth = 1; } + // + // save this because barLinesMap may be modified later and invalidate barLinesMapIt + // + bool barLinesMapItIsEnd = (barLinesMapIt == barLinesMap.end()); + // // bar line (when processed BEFORE the space) // - if (barLinesMapIt != barLinesMap.end()) { + if (!barLinesMapItIsEnd) { if constexpr (0x70 <= VERSION) { @@ -1356,7 +1361,7 @@ TtbtFileTablature(const tbt_file_t &t) { // // bar line (when processed AFTER the space) // - if (barLinesMapIt != barLinesMap.end()) { + if (!barLinesMapItIsEnd) { if constexpr (0x70 <= VERSION) {