theme-node-drawing: don't crash if st_theme_node_paint() is called on an empty area
When st_theme_node_paint() was called with zero width or height and a theme node with a shadow, we'd crash because we'd fail to allocate a texture with an empty size, then unreference the NULL pointer. https://bugzilla.redhat.com/show_bug.cgi?id=748293 https://bugzilla.gnome.org/show_bug.cgi?id=668050
This commit is contained in:
parent
91ca86ffe4
commit
e58c82fc04
@ -1306,6 +1306,8 @@ st_theme_node_render_resources (StThemeNode *node,
|
||||
StShadow *background_image_shadow_spec;
|
||||
const char *background_image;
|
||||
|
||||
g_return_if_fail (width > 0 && height > 0);
|
||||
|
||||
texture_cache = st_texture_cache_get_default ();
|
||||
|
||||
/* FIXME - need to separate this into things that need to be recomputed on
|
||||
@ -1409,9 +1411,11 @@ st_theme_node_render_resources (StThemeNode *node,
|
||||
else if (node->background_color.alpha > 0 || has_border)
|
||||
{
|
||||
CoglHandle buffer, offscreen;
|
||||
int texture_width = ceil (width);
|
||||
int texture_height = ceil (height);
|
||||
|
||||
buffer = cogl_texture_new_with_size (width,
|
||||
height,
|
||||
buffer = cogl_texture_new_with_size (texture_width,
|
||||
texture_height,
|
||||
COGL_TEXTURE_NO_SLICING,
|
||||
COGL_PIXEL_FORMAT_ANY);
|
||||
offscreen = cogl_offscreen_new_to_texture (buffer);
|
||||
@ -1925,6 +1929,9 @@ st_theme_node_paint (StThemeNode *node,
|
||||
allocation.x2 = width;
|
||||
allocation.y2 = height;
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
if (node->alloc_width != width || node->alloc_height != height)
|
||||
st_theme_node_render_resources (node, width, height);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user