summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-02-02 10:05:57 +0000
committerArturo Espinosa <unammx@src.gnome.org>2000-02-02 10:05:57 +0000
commite9f75f6bd857671a3387f4cb596a0b3342855cbd (patch)
tree05a1490d0429aca1be5a54a074da75095227503c
parent51a0dc303d8c414d86cb0316215192155c628482 (diff)
downloadgtk+-e9f75f6bd857671a3387f4cb596a0b3342855cbd.tar.gz
Added sanity check for width and height being >= 0. Also, do nothing if
2000-02-03 Federico Mena Quintero <federico@helixcode.com> * gdk-pixbuf/gdk-pixbuf-render.c (gdk_pixbuf_render_threshold_alpha): Added sanity check for width and height being >= 0. Also, do nothing if either of them is zero. Thanks to Ettore for pointing this out. (gdk_pixbuf_render_to_drawable): Likewise. (gdk_pixbuf_render_to_drawable_alpha): Likewise.
-rw-r--r--gdk-pixbuf/ChangeLog9
-rw-r--r--gdk/gdkpixbuf-render.c13
2 files changed, 22 insertions, 0 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index 3f74782181..481bb32362 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,3 +1,12 @@
+2000-02-03 Federico Mena Quintero <federico@helixcode.com>
+
+ * gdk-pixbuf/gdk-pixbuf-render.c
+ (gdk_pixbuf_render_threshold_alpha): Added sanity check for width
+ and height being >= 0. Also, do nothing if either of them is
+ zero. Thanks to Ettore for pointing this out.
+ (gdk_pixbuf_render_to_drawable): Likewise.
+ (gdk_pixbuf_render_to_drawable_alpha): Likewise.
+
2000-02-02 Federico Mena Quintero <federico@helixcode.com>
* gdk-pixbuf/io-gif.c (gif_get_lzw): Removed debugging g_print.
diff --git a/gdk/gdkpixbuf-render.c b/gdk/gdkpixbuf-render.c
index 742e49c4c8..19bf30deab 100644
--- a/gdk/gdkpixbuf-render.c
+++ b/gdk/gdkpixbuf-render.c
@@ -68,11 +68,15 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
g_return_if_fail (apb->bits_per_sample == 8);
g_return_if_fail (bitmap != NULL);
+ g_return_if_fail (width >= 0 && height >= 0);
g_return_if_fail (src_x >= 0 && src_x + width <= apb->width);
g_return_if_fail (src_y >= 0 && src_y + height <= apb->height);
g_return_if_fail (alpha_threshold >= 0 && alpha_threshold <= 255);
+ if (width == 0 || height == 0)
+ return;
+
gc = gdk_gc_new (bitmap);
if (!apb->has_alpha) {
@@ -134,6 +138,7 @@ remove_alpha (ArtPixBuf *apb, int x, int y, int width, int height, int *rowstrid
g_assert (apb->n_channels == 4);
g_assert (apb->has_alpha);
+ g_assert (width > 0 && height > 0);
g_assert (x >= 0 && x + width <= apb->width);
g_assert (y >= 0 && y + height <= apb->height);
@@ -207,9 +212,13 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
+ g_return_if_fail (width >= 0 && height >= 0);
g_return_if_fail (src_x >= 0 && src_x + width <= apb->width);
g_return_if_fail (src_y >= 0 && src_y + height <= apb->height);
+ if (width == 0 || height == 0)
+ return;
+
/* This will have to be modified once libart supports other image types.
* Also, GdkRGB does not have gdk_draw_rgb_32_image_dithalign(), so we
* have to pack the buffer first.
@@ -287,9 +296,13 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable,
g_return_if_fail (apb->bits_per_sample == 8);
g_return_if_fail (drawable != NULL);
+ g_return_if_fail (width >= 0 && height >= 0);
g_return_if_fail (src_x >= 0 && src_x + width <= apb->width);
g_return_if_fail (src_y >= 0 && src_y + height <= apb->height);
+ if (width == 0 || height == 0)
+ return;
+
gc = gdk_gc_new (drawable);
if (apb->has_alpha) {