Blame SOURCES/0002-pixops-Be-smarter-than-gcc-s-optimizer.patch

159db5
From dd4b061c27dc0865c8f8987d294de6e04b321c18 Mon Sep 17 00:00:00 2001
159db5
From: Benjamin Otte <otte@redhat.com>
159db5
Date: Sat, 22 Aug 2015 23:06:23 +0200
159db5
Subject: [PATCH 2/2] pixops: Be smarter than gcc's optimizer
159db5
159db5
gcc realizes that the overflow checks aren't necessary. Why not?
159db5
159db5
Well, if an int overflows, the behavior is undefined. And turning on
159db5
-fomit-instructions is valid behavior in an undefined situation.
159db5
---
159db5
 gdk-pixbuf/pixops/pixops.c | 15 +++++++--------
159db5
 1 file changed, 7 insertions(+), 8 deletions(-)
159db5
159db5
diff --git a/gdk-pixbuf/pixops/pixops.c b/gdk-pixbuf/pixops/pixops.c
159db5
index b7951c7..5564a40 100644
159db5
--- a/gdk-pixbuf/pixops/pixops.c
159db5
+++ b/gdk-pixbuf/pixops/pixops.c
159db5
@@ -1272,18 +1272,17 @@ make_filter_table (PixopsFilter *filter)
159db5
   int i_offset, j_offset;
159db5
   int n_x = filter->x.n;
159db5
   int n_y = filter->y.n;
159db5
-  int n_weights;
159db5
   int *weights;
159db5
 
159db5
-  n_weights = SUBSAMPLE * SUBSAMPLE * n_x;
159db5
-  if (n_weights / (SUBSAMPLE * SUBSAMPLE) != n_x)
159db5
-    return NULL; /* overflow, bail */
159db5
+  /* check n_x doesn't overflow */
159db5
+  if (G_MAXINT / (SUBSAMPLE * SUBSAMPLE) < n_x)
159db5
+    return NULL;
159db5
 
159db5
-  n_weights *= n_y;
159db5
-  if (n_weights / (SUBSAMPLE * SUBSAMPLE * n_x) != n_y)
159db5
-    return NULL; /* overflow, bail */
159db5
+  /* check n_y doesn't overflow */
159db5
+  if (G_MAXINT / (SUBSAMPLE * SUBSAMPLE * n_x) < n_y)
159db5
+    return NULL;
159db5
 
159db5
-  weights = g_try_new (int, n_weights);
159db5
+  weights = g_try_new (int, SUBSAMPLE * SUBSAMPLE * n_x * n_y);
159db5
   if (!weights)
159db5
     return NULL; /* overflow, bail */
159db5
 
159db5
-- 
159db5
2.5.2
159db5