From 5b3c5d3782507b24dc80f677f7a21d5622d126b4 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 16 Feb 2021 15:53:09 -0700 Subject: [PATCH] libtemporal: fix implementation of timepos_t::max() to avoid overflow for Beats time --- libs/temporal/temporal/timeline.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/temporal/temporal/timeline.h b/libs/temporal/temporal/timeline.h index 6f61d7c069..1c971ce125 100644 --- a/libs/temporal/temporal/timeline.h +++ b/libs/temporal/temporal/timeline.h @@ -211,7 +211,10 @@ class LIBTEMPORAL_API timepos_t : public int62_t { bool string_to (std::string const & str); std::string to_string () const; - static timepos_t max (TimeDomain td) { return timepos_t (td != AudioTime, int62_t::max); } + /* note that the value returned if the time domain is audio is larger + than can be represented in musical time (for any realistic tempos). + */ + static timepos_t max (TimeDomain td) { if (td == AudioTime) { return timepos_t (false, int62_t::max); } else { return timepos_t (std::numeric_limits::max()); }} static timepos_t smallest_step (TimeDomain td) { return timepos_t (td != AudioTime, 1); } private: