]> git.donarmstrong.com Git - lilypond.git/commitdiff
Use signed arithmetic to avoid overflow.
authorJoe Neeman <joeneeman@gmail.com>
Thu, 26 Aug 2010 23:18:14 +0000 (16:18 -0700)
committerJoe Neeman <joeneeman@gmail.com>
Sat, 28 Aug 2010 00:11:07 +0000 (17:11 -0700)
lily/page-breaking.cc

index 88f55b896c79b4868fd6b4e8ba8f8a59e7973457..543665f97bb4d53b7ff3e74940b796b75190602d 100644 (file)
@@ -851,17 +851,17 @@ Page_breaking::line_divisions_rec (vsize system_count,
                                   Line_division *cur_division)
 {
   vsize my_index = cur_division->size ();
-  vsize others_min = 0;
-  vsize others_max = 0;
+  int others_min = 0;
+  int others_max = 0;
 
   for (vsize i = my_index + 1; i < min_sys.size (); i++)
     {
       others_min += min_sys[i];
       others_max += max_sys[i];
     }
-  others_max = min (others_max, system_count);
-  vsize real_min = max (min_sys[my_index], system_count - others_max);
-  vsize real_max = min (max_sys[my_index], system_count - others_min);
+  others_max = min (others_max, (int) system_count);
+  int real_min = max ((int) min_sys[my_index], (int) system_count - others_max);
+  int real_max = min ((int) max_sys[my_index], (int) system_count - others_min);
 
   if (real_min > real_max || real_min <= 0)
     {
@@ -872,7 +872,7 @@ Page_breaking::line_divisions_rec (vsize system_count,
       return;
     }
 
-  for (vsize i = real_min; i <= real_max; i++)
+  for (int i = real_min; i <= real_max; i++)
     {
       cur_division->push_back (i);
       if (my_index == min_sys.size () - 1)