diff options
author | Matthias Clasen <mclasen@redhat.com> | 2006-01-17 20:02:54 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2006-01-17 20:02:54 +0000 |
commit | 536977184787ee79fa9136d620de69ac0a836c99 (patch) | |
tree | fa37c54aede271943354a307e1a6b74f7809382d /modules/engines | |
parent | 7661da2306a4daa5e490d1231b6c51d3c74374c7 (diff) | |
download | gtk+-536977184787ee79fa9136d620de69ac0a836c99.tar.gz |
If the src positions for gradients are nonsensical, don't render anything,
2006-01-17 Matthias Clasen <mclasen@redhat.com>
* pixbuf-render.c: If the src positions for gradients
are nonsensical, don't render anything, rather than
read out of bounds.
Diffstat (limited to 'modules/engines')
-rw-r--r-- | modules/engines/pixbuf/ChangeLog | 6 | ||||
-rw-r--r-- | modules/engines/pixbuf/pixbuf-render.c | 53 |
2 files changed, 43 insertions, 16 deletions
diff --git a/modules/engines/pixbuf/ChangeLog b/modules/engines/pixbuf/ChangeLog index 77b47f4bef..68f29c810e 100644 --- a/modules/engines/pixbuf/ChangeLog +++ b/modules/engines/pixbuf/ChangeLog @@ -1,3 +1,9 @@ +2006-01-17 Matthias Clasen <mclasen@redhat.com> + + * pixbuf-render.c: If the src positions for gradients + are nonsensical, don't render anything, rather than + read out of bounds. + 2006-01-16 Matthias Clasen <mclasen@redhat.com> * pixbuf-draw.c: diff --git a/modules/engines/pixbuf/pixbuf-render.c b/modules/engines/pixbuf/pixbuf-render.c index 4d965a057c..916bbd87ca 100644 --- a/modules/engines/pixbuf/pixbuf-render.c +++ b/modules/engines/pixbuf/pixbuf-render.c @@ -43,6 +43,12 @@ bilinear_gradient (GdkPixbuf *src, GdkPixbuf *result; int i, j, k; + if (src_x == 0 || src_y == 0) + { + g_warning ("invalid source position for bilinear gradient\n"); + return NULL; + } + p1 = src_pixels + (src_y - 1) * src_rowstride + (src_x - 1) * n_channels; p2 = p1 + n_channels; p3 = src_pixels + src_y * src_rowstride + (src_x - 1) * n_channels; @@ -96,6 +102,12 @@ horizontal_gradient (GdkPixbuf *src, GdkPixbuf *result; int i, j, k; + if (src_x == 0) + { + g_warning ("invalid source position for horizontal gradient\n"); + return NULL; + } + result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, n_channels == 4, 8, width, height); dest_rowstride = gdk_pixbuf_get_rowstride (result); @@ -145,6 +157,12 @@ vertical_gradient (GdkPixbuf *src, GdkPixbuf *result; int i, j; + if (src_y == 0) + { + g_warning ("invalid source position for vertical gradient\n"); + return NULL; + } + top_pixels = src_pixels + (src_y - 1) * src_rowstride + (src_x) * n_channels; bottom_pixels = top_pixels + src_rowstride; @@ -304,7 +322,7 @@ pixbuf_render (GdkPixbuf *src, gint dest_width, gint dest_height) { - GdkPixbuf *tmp_pixbuf; + GdkPixbuf *tmp_pixbuf = NULL; GdkRectangle rect; int x_offset, y_offset; gboolean has_alpha = gdk_pixbuf_get_has_alpha (src); @@ -382,7 +400,7 @@ pixbuf_render (GdkPixbuf *src, x_offset = rect.x - dest_x; y_offset = rect.y - dest_y; } - else + else if (src_width > 0 && src_height > 0) { double x_scale = (double)dest_width / src_width; double y_scale = (double)dest_height / src_height; @@ -415,22 +433,25 @@ pixbuf_render (GdkPixbuf *src, y_offset = 0; } - if (mask) + if (tmp_pixbuf) { - gdk_pixbuf_render_threshold_alpha (tmp_pixbuf, mask, - x_offset, y_offset, - rect.x, rect.y, - rect.width, rect.height, - 128); + if (mask) + { + gdk_pixbuf_render_threshold_alpha (tmp_pixbuf, mask, + x_offset, y_offset, + rect.x, rect.y, + rect.width, rect.height, + 128); + } + + gdk_draw_pixbuf (window, NULL, tmp_pixbuf, + x_offset, y_offset, + rect.x, rect.y, + rect.width, rect.height, + GDK_RGB_DITHER_NORMAL, + 0, 0); + g_object_unref (tmp_pixbuf); } - - gdk_draw_pixbuf (window, NULL, tmp_pixbuf, - x_offset, y_offset, - rect.x, rect.y, - rect.width, rect.height, - GDK_RGB_DITHER_NORMAL, - 0, 0); - g_object_unref (tmp_pixbuf); } ThemePixbuf * |