[gnome-shell] theme-node-drawing: don't crash if st_theme_node_paint() is called on an empty area



commit e58c82fc0483b7ec8c3c742afa1bbbe7d2807c35
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 1e7ac5b..12d86d3 100644
--- a/src/st/st-theme-node-drawing.c
+++ b/src/st/st-theme-node-drawing.c
@@ -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);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]