From 08c5bc3ff87e25b1b575283f91546e5f77c591a5 Mon Sep 17 00:00:00 2001 From: Devon Schudy Date: Wed, 26 Mar 2014 14:58:20 -0400 Subject: [PATCH] Fix infinite loop in Completion_heads_engraver at invalid measure position (issue 3888). * Completion_heads_engraver now gives a programming_error instead of trying to make negative-duration notes. * intlog2 with a nonpositive argument now gives an error instead of an infinite loop. --- lily/completion-note-heads-engraver.cc | 6 ++++++ lily/misc.cc | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index 5775ef188a..4192b58be1 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -117,6 +117,12 @@ Completion_heads_engraver::next_moment (Rational const ¬e_len) } Moment result = *l - *e; + if (result < 0) + { + programming_error ("invalid measure position: " + + e->to_string () + " of " + l->to_string ()); + return 0; + } Moment const *unit = unsmob_moment (get_property ("completionUnit")); if (unit) diff --git a/lily/misc.cc b/lily/misc.cc index f104f98baa..2adc250481 100644 --- a/lily/misc.cc +++ b/lily/misc.cc @@ -30,7 +30,8 @@ int intlog2 (int d) { - assert (d); + if (d <= 0) + error ("intlog2 with negative argument: " + to_string (d)); int i = 0; while ((d != 1)) { -- 2.39.2