[glom] EggSpreadTable: Avoid a division by zero if there are no lines.



commit f28993ed84bb8f62480443cd6fbd79b1cbad83bc
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Dec 3 09:51:22 2014 +0100

    EggSpreadTable: Avoid a division by zero if there are no lines.
    
    Found by Coverity Scan.
    
    I have pushed this to libegg too:
    https://git.gnome.org/browse/libegg/commit/?id=54489b5c3ba32c517a932f6b4402c06b599a29d1

 .../eggspreadtable/eggspreadtablednd.c             |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/glom/utility_widgets/eggspreadtable/eggspreadtablednd.c 
b/glom/utility_widgets/eggspreadtable/eggspreadtablednd.c
index e342880..0b7e94b 100644
--- a/glom/utility_widgets/eggspreadtable/eggspreadtablednd.c
+++ b/glom/utility_widgets/eggspreadtable/eggspreadtablednd.c
@@ -490,7 +490,12 @@ get_spread_table_dimensions (EggSpreadTableDnd *spread_table,
     *item_spacing = local_item_spacing;
 
   if (line_width)
-    *line_width = (local_full_size - (local_spacing * (lines -1))) / lines;
+    {
+      if (lines == 0)
+        *line_width = 0;
+      else 
+        *line_width = (local_full_size - (local_spacing * (lines -1))) / lines;
+    }
 }
 
 static void


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