[mutter] meta-window-actor: Fix a potential crash in the window shaping code
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] meta-window-actor: Fix a potential crash in the window shaping code
- Date: Mon, 25 Jun 2012 18:07:47 +0000 (UTC)
commit a2f2e07e9be565da686b748b3245bd969f560c83
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Jun 13 13:51:08 2012 -0400
meta-window-actor: Fix a potential crash in the window shaping code
There was a potential case where we were trying to use uninitialized memory,
in the case where the X server threw an error during XShapeGetRectangles.
In this case, we need to use the implicit shape for the window, which means
we need to rearrange code flow to make it work.
https://bugzilla.gnome.org/show_bug.cgi?id=677977
src/compositor/meta-window-actor.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index 2dfde8b..70ec535 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -2216,7 +2216,7 @@ check_needs_reshape (MetaWindowActor *self)
MetaScreen *screen = priv->screen;
MetaDisplay *display = meta_screen_get_display (screen);
MetaFrameBorders borders;
- cairo_region_t *region;
+ cairo_region_t *region = NULL;
cairo_rectangle_int_t client_area;
if (!priv->needs_reshape)
@@ -2240,7 +2240,6 @@ check_needs_reshape (MetaWindowActor *self)
Display *xdisplay = meta_display_get_xdisplay (display);
XRectangle *rects;
int n_rects, ordering;
- cairo_rectangle_int_t *cairo_rects = NULL;
meta_error_trap_push (display);
rects = XShapeGetRectangles (xdisplay,
@@ -2253,7 +2252,8 @@ check_needs_reshape (MetaWindowActor *self)
if (rects)
{
int i;
- cairo_rects = g_new (cairo_rectangle_int_t, n_rects);
+ cairo_rectangle_int_t *cairo_rects = g_new (cairo_rectangle_int_t, n_rects);
+
for (i = 0; i < n_rects; i ++)
{
cairo_rects[i].x = rects[i].x + client_area.x;
@@ -2261,14 +2261,15 @@ check_needs_reshape (MetaWindowActor *self)
cairo_rects[i].width = rects[i].width;
cairo_rects[i].height = rects[i].height;
}
+
XFree (rects);
+ region = cairo_region_create_rectangles (cairo_rects, n_rects);
+ g_free (cairo_rects);
}
-
- region = cairo_region_create_rectangles (cairo_rects, n_rects);
- g_free (cairo_rects);
}
- else
#endif
+
+ if (region == NULL)
{
/* If we don't have a shape on the server, that means that
* we have an implicit shape of one rectangle covering the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]