summaryrefslogtreecommitdiff
path: root/graphics/imlib/patches/patch-an
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/imlib/patches/patch-an')
-rw-r--r--graphics/imlib/patches/patch-an23
1 files changed, 23 insertions, 0 deletions
diff --git a/graphics/imlib/patches/patch-an b/graphics/imlib/patches/patch-an
new file mode 100644
index 00000000000..7c056e8a577
--- /dev/null
+++ b/graphics/imlib/patches/patch-an
@@ -0,0 +1,23 @@
+$NetBSD: patch-an,v 1.1.2.2 2004/12/13 18:03:27 salo Exp $
+
+--- gdk_imlib/misc.c.orig 2002-03-04 18:06:32.000000000 +0100
++++ gdk_imlib/misc.c 2004-12-10 10:15:22.000000000 +0100
+@@ -1355,11 +1355,16 @@
+
+ /*
+ * Make sure we don't wrap on our memory allocations
++ * we check G_MAX_INT/4 because rend.c malloc's w * h * bpp
++ * + 3 is safety margin
+ */
+
+ void *_gdk_malloc_image(unsigned int w, unsigned int h)
+ {
+- if( w > 32767 || h > 32767)
++ if (w <= 0 || w > 32767 ||
++ h <= 0 || h > 32767 ||
++ h >= (G_MAXINT/4 - 1) / w)
+ return NULL;
+- return malloc(w * h * 3);
++ return malloc(w * h * 3 + 3);
+ }
++