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:

committed by
Matthias Clasen

parent
7661da2306
commit
5369771847
@ -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>
|
2006-01-16 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* pixbuf-draw.c:
|
* pixbuf-draw.c:
|
||||||
|
@ -43,6 +43,12 @@ bilinear_gradient (GdkPixbuf *src,
|
|||||||
GdkPixbuf *result;
|
GdkPixbuf *result;
|
||||||
int i, j, k;
|
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;
|
p1 = src_pixels + (src_y - 1) * src_rowstride + (src_x - 1) * n_channels;
|
||||||
p2 = p1 + n_channels;
|
p2 = p1 + n_channels;
|
||||||
p3 = src_pixels + src_y * src_rowstride + (src_x - 1) * n_channels;
|
p3 = src_pixels + src_y * src_rowstride + (src_x - 1) * n_channels;
|
||||||
@ -96,6 +102,12 @@ horizontal_gradient (GdkPixbuf *src,
|
|||||||
GdkPixbuf *result;
|
GdkPixbuf *result;
|
||||||
int i, j, k;
|
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,
|
result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, n_channels == 4, 8,
|
||||||
width, height);
|
width, height);
|
||||||
dest_rowstride = gdk_pixbuf_get_rowstride (result);
|
dest_rowstride = gdk_pixbuf_get_rowstride (result);
|
||||||
@ -145,6 +157,12 @@ vertical_gradient (GdkPixbuf *src,
|
|||||||
GdkPixbuf *result;
|
GdkPixbuf *result;
|
||||||
int i, j;
|
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;
|
top_pixels = src_pixels + (src_y - 1) * src_rowstride + (src_x) * n_channels;
|
||||||
bottom_pixels = top_pixels + src_rowstride;
|
bottom_pixels = top_pixels + src_rowstride;
|
||||||
|
|
||||||
@ -304,7 +322,7 @@ pixbuf_render (GdkPixbuf *src,
|
|||||||
gint dest_width,
|
gint dest_width,
|
||||||
gint dest_height)
|
gint dest_height)
|
||||||
{
|
{
|
||||||
GdkPixbuf *tmp_pixbuf;
|
GdkPixbuf *tmp_pixbuf = NULL;
|
||||||
GdkRectangle rect;
|
GdkRectangle rect;
|
||||||
int x_offset, y_offset;
|
int x_offset, y_offset;
|
||||||
gboolean has_alpha = gdk_pixbuf_get_has_alpha (src);
|
gboolean has_alpha = gdk_pixbuf_get_has_alpha (src);
|
||||||
@ -382,7 +400,7 @@ pixbuf_render (GdkPixbuf *src,
|
|||||||
x_offset = rect.x - dest_x;
|
x_offset = rect.x - dest_x;
|
||||||
y_offset = rect.y - dest_y;
|
y_offset = rect.y - dest_y;
|
||||||
}
|
}
|
||||||
else
|
else if (src_width > 0 && src_height > 0)
|
||||||
{
|
{
|
||||||
double x_scale = (double)dest_width / src_width;
|
double x_scale = (double)dest_width / src_width;
|
||||||
double y_scale = (double)dest_height / src_height;
|
double y_scale = (double)dest_height / src_height;
|
||||||
@ -415,6 +433,8 @@ pixbuf_render (GdkPixbuf *src,
|
|||||||
y_offset = 0;
|
y_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tmp_pixbuf)
|
||||||
|
{
|
||||||
if (mask)
|
if (mask)
|
||||||
{
|
{
|
||||||
gdk_pixbuf_render_threshold_alpha (tmp_pixbuf, mask,
|
gdk_pixbuf_render_threshold_alpha (tmp_pixbuf, mask,
|
||||||
@ -432,6 +452,7 @@ pixbuf_render (GdkPixbuf *src,
|
|||||||
0, 0);
|
0, 0);
|
||||||
g_object_unref (tmp_pixbuf);
|
g_object_unref (tmp_pixbuf);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ThemePixbuf *
|
ThemePixbuf *
|
||||||
theme_pixbuf_new (void)
|
theme_pixbuf_new (void)
|
||||||
|
Reference in New Issue
Block a user