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.
This commit is contained in:
Matthias Clasen 2006-01-17 20:02:54 +00:00 committed by Matthias Clasen
parent 7661da2306
commit 5369771847
2 changed files with 43 additions and 16 deletions

View File

@ -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:

View File

@ -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 *