[gnumeric] Print: fix division by zero.



commit 1add40074b0c5940ce90aa7f6ad4ef878113f303
Author: Morten Welinder <terra gnome org>
Date:   Wed May 27 16:21:10 2015 -0400

    Print: fix division by zero.

 ChangeLog   |    3 +++
 NEWS        |    2 +-
 src/print.c |    6 ++----
 3 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5c9062f..09906c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-05-27  Morten Welinder  <terra gnome org>
 
+       * src/print.c (compute_scale_fit_to): Attempt a workaround for fp
+       division by zero.  Fixes #749917.
+
        * src/gnm-so-filled.c (gnm_so_filled_draw_cairo): Plug leak.
 
 2015-05-16  Jean Brefort  <jean brefort normalesup org>
diff --git a/NEWS b/NEWS
index c8ca296..a9acc2a 100644
--- a/NEWS
+++ b/NEWS
@@ -17,7 +17,7 @@ Morten:
        * Fuzzed file fixes.  [#748595] [#748597] [#749031] [#749030]
          [#749069] [#748533] [#749118] [#749166] [#749181] [#749184]
          [#749236] [#749240] [#749234] [#749235] [#749271] [#749270]
-         [#749424]
+         [#749424] [#749917]
        * Make solver check linearity of model.
        * Fix xls saving of marker style.  [#749185]
        * Make compilation with clang work again.  [#749138]
diff --git a/src/print.c b/src/print.c
index baf8160..e6cd990 100644
--- a/src/print.c
+++ b/src/print.c
@@ -821,8 +821,7 @@ compute_scale_fit_to (Sheet const *sheet,
        /* We first calculate the max percentage needed */
 
        max_p = (pages * usable)/(extent + pages * header);
-       if (max_p > max_percent)
-               max_p = max_percent;
+       max_p = CLAMP (max_p, 0.01, max_percent);
 
        max_pages = paginate (NULL, sheet, start, end, usable/max_p - header,
                              repeat, repeat_start, repeat_end,
@@ -834,8 +833,7 @@ compute_scale_fit_to (Sheet const *sheet,
        /* The we calculate the min percentage */
 
        min_p = usable/(extent + header);
-       if (min_p > max_percent)
-               min_p = max_percent;
+       min_p = CLAMP (min_p, 0.01, max_percent);
 
        paginate (NULL, sheet, start, end, usable/min_p - header,
                  repeat, repeat_start, repeat_end,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]