mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 17:10:40 -05:00
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
This commit is contained in:
parent
f5e48223c9
commit
a2f2e07e9b
@ -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);
|
||||
XFree (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
|
||||
|
Loading…
Reference in New Issue
Block a user