[gnome-shell/gnome-3-2] theme-node-drawing: don't crash if st_theme_node_paint() is called on an empty area
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-2] theme-node-drawing: don't crash if st_theme_node_paint() is called on an empty area
- Date: Wed, 18 Jan 2012 15:31:22 +0000 (UTC)
commit 0cfedcaad652c44941705753e64978a92ce13941
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Mon Jan 16 14:50:47 2012 -0500
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
src/st/st-theme-node-drawing.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c
index b834811..29b2d57 100644
--- a/src/st/st-theme-node-drawing.c
+++ b/src/st/st-theme-node-drawing.c
@@ -1314,6 +1314,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
@@ -1417,9 +1419,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);
@@ -1933,6 +1937,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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]