]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix infinite loop in Completion_heads_engraver at invalid measure position (issue...
authorDevon Schudy <dschudy@gmail.com>
Wed, 26 Mar 2014 18:58:20 +0000 (14:58 -0400)
committerDavid Kastrup <dak@gnu.org>
Fri, 4 Apr 2014 19:52:25 +0000 (21:52 +0200)
* 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
lily/misc.cc

index 5775ef188a17e8bbd2cd3ab45c001115a1782d77..4192b58be1a9f12696aa2faa8b9f284bdf0e5445 100644 (file)
@@ -117,6 +117,12 @@ Completion_heads_engraver::next_moment (Rational const &note_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)
index f104f98baa7be06dc611011d5995d97bddb72fb5..2adc250481b978bf75a196955787bd3fbca7d852 100644 (file)
@@ -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))
     {