From a417cbae4be1e18a73cb60821fe9479ec9ac906d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 17 Nov 2021 08:58:49 -0700 Subject: [PATCH] tempo map: fix a potential bug (not seen in the wild) when generating the grid the "p" variable could point to _points.end(), so we cannot indirect and use p->sclock() value unconditionally. --- libs/temporal/tempo.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index a56a1fe52b..244a582bc1 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -1926,7 +1926,15 @@ TempoMap::get_grid (TempoMapPoints& ret, superclock_t start, superclock_t end, u DEBUG_TRACE (DEBUG::Grid, string_compose ("start %1 end %2 bbt %3 find first/limit with limit @ = %4\n", start, end, bbt, *p)); - while (start < p->sclock() && start < end) { + superclock_t limit; + + if (p == _points.end()) { + limit = end; + } else { + limit = std::min (p->sclock(), end); + } + + while (start < limit) { /* add point to grid, perhaps */