defensive programming; check meta_screen_get_compositor_data() throughout
2008-06-05 Thomas Thurman <tthurman@gnome.org> * src/compositor/compositor-xrender.c (paint_root, destroy_win, create_root_buffer, paint_windows, repair_screen, window_has_shadow, xrender_set_active_window, paint_dock_shadows, unmap_win, restack_win, make_shadow, resize_win, process_property_notify, free_win, process_configure_notify, process_circulate_notify, add_damage): defensive programming; check meta_screen_get_compositor_data() throughout in case it returns NULL. In particular, when this happened in a certain situation in xrender_set_active_window this caused a segfault; refs #530702 (and LP#178953 has more data) but this doesn't close them. svn path=/trunk/; revision=3751
This commit is contained in:
parent
e9388f4345
commit
5dbe941495
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
2008-06-05 Thomas Thurman <tthurman@gnome.org>
|
||||||
|
|
||||||
|
* src/compositor/compositor-xrender.c (paint_root, destroy_win,
|
||||||
|
create_root_buffer, paint_windows, repair_screen, window_has_shadow,
|
||||||
|
xrender_set_active_window, paint_dock_shadows, unmap_win, restack_win,
|
||||||
|
make_shadow, resize_win, process_property_notify, free_win,
|
||||||
|
process_configure_notify, process_circulate_notify, add_damage):
|
||||||
|
defensive programming; check meta_screen_get_compositor_data()
|
||||||
|
throughout in case it returns NULL. In particular, when this
|
||||||
|
happened in a certain situation in xrender_set_active_window
|
||||||
|
this caused a segfault; refs #530702 (and LP#178953 has more data)
|
||||||
|
but this doesn't close them.
|
||||||
|
|
||||||
2008-06-02 Thomas Thurman <tthurman@gnome.org>
|
2008-06-02 Thomas Thurman <tthurman@gnome.org>
|
||||||
|
|
||||||
* NEWS: 2.23.34 release.
|
* NEWS: 2.23.34 release.
|
||||||
|
@ -478,18 +478,28 @@ make_shadow (MetaDisplay *display,
|
|||||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||||
XImage *ximage;
|
XImage *ximage;
|
||||||
guchar *data;
|
guchar *data;
|
||||||
shadow *shad = info->shadows[shadow_type];
|
shadow *shad;
|
||||||
int msize = shad->gaussian_map->size;
|
int msize;
|
||||||
int ylimit, xlimit;
|
int ylimit, xlimit;
|
||||||
int swidth = width + msize;
|
int swidth, sheight;
|
||||||
int sheight = height + msize;
|
int centre;
|
||||||
int centre = msize / 2;
|
|
||||||
int x, y;
|
int x, y;
|
||||||
guchar d;
|
guchar d;
|
||||||
int x_diff;
|
int x_diff;
|
||||||
int opacity_int = (int)(opacity * 25);
|
int opacity_int = (int)(opacity * 25);
|
||||||
int screen_number = meta_screen_get_screen_number (screen);
|
int screen_number = meta_screen_get_screen_number (screen);
|
||||||
|
|
||||||
|
if (info==NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
shad = info->shadows[shadow_type];
|
||||||
|
msize = shad->gaussian_map->size;
|
||||||
|
swidth = width + msize;
|
||||||
|
sheight = height + msize;
|
||||||
|
centre = msize / 2;
|
||||||
|
|
||||||
data = g_malloc (swidth * sheight * sizeof (guchar));
|
data = g_malloc (swidth * sheight * sizeof (guchar));
|
||||||
|
|
||||||
ximage = XCreateImage (xdisplay, DefaultVisual (xdisplay, screen_number),
|
ximage = XCreateImage (xdisplay, DefaultVisual (xdisplay, screen_number),
|
||||||
@ -824,6 +834,11 @@ create_root_buffer (MetaScreen *screen)
|
|||||||
Visual *visual;
|
Visual *visual;
|
||||||
int depth, screen_width, screen_height, screen_number;
|
int depth, screen_width, screen_height, screen_number;
|
||||||
|
|
||||||
|
if (info == NULL)
|
||||||
|
{
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
meta_screen_get_size (screen, &screen_width, &screen_height);
|
meta_screen_get_size (screen, &screen_width, &screen_height);
|
||||||
screen_number = meta_screen_get_screen_number (screen);
|
screen_number = meta_screen_get_screen_number (screen);
|
||||||
visual = DefaultVisual (xdisplay, screen_number);
|
visual = DefaultVisual (xdisplay, screen_number);
|
||||||
@ -851,6 +866,11 @@ paint_root (MetaScreen *screen,
|
|||||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
|
if (info == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_return_if_fail (root_buffer != None);
|
g_return_if_fail (root_buffer != None);
|
||||||
|
|
||||||
if (info->root_tile == None)
|
if (info->root_tile == None)
|
||||||
@ -869,7 +889,7 @@ window_has_shadow (MetaCompWindow *cw)
|
|||||||
{
|
{
|
||||||
MetaCompScreen *info = meta_screen_get_compositor_data (cw->screen);
|
MetaCompScreen *info = meta_screen_get_compositor_data (cw->screen);
|
||||||
|
|
||||||
if (info->have_shadows == FALSE)
|
if (info == NULL || info->have_shadows == FALSE)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Always put a shadow around windows with a frame - This should override
|
/* Always put a shadow around windows with a frame - This should override
|
||||||
@ -1070,6 +1090,11 @@ paint_dock_shadows (MetaScreen *screen,
|
|||||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||||
GSList *d;
|
GSList *d;
|
||||||
|
|
||||||
|
if (info == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (d = info->dock_windows; d; d = d->next)
|
for (d = info->dock_windows; d; d = d->next)
|
||||||
{
|
{
|
||||||
MetaCompWindow *cw = d->data;
|
MetaCompWindow *cw = d->data;
|
||||||
@ -1109,6 +1134,11 @@ paint_windows (MetaScreen *screen,
|
|||||||
MetaCompWindow *cw;
|
MetaCompWindow *cw;
|
||||||
XserverRegion paint_region, desktop_region;
|
XserverRegion paint_region, desktop_region;
|
||||||
|
|
||||||
|
if (info == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
meta_screen_get_size (screen, &screen_width, &screen_height);
|
meta_screen_get_size (screen, &screen_width, &screen_height);
|
||||||
screen_number = meta_screen_get_screen_number (screen);
|
screen_number = meta_screen_get_screen_number (screen);
|
||||||
xroot = meta_screen_get_xroot (screen);
|
xroot = meta_screen_get_xroot (screen);
|
||||||
@ -1364,7 +1394,7 @@ repair_screen (MetaScreen *screen)
|
|||||||
MetaDisplay *display = meta_screen_get_display (screen);
|
MetaDisplay *display = meta_screen_get_display (screen);
|
||||||
Display *xdisplay = meta_display_get_xdisplay (display);
|
Display *xdisplay = meta_display_get_xdisplay (display);
|
||||||
|
|
||||||
if (info->all_damage != None)
|
if (info!=NULL && info->all_damage != None)
|
||||||
{
|
{
|
||||||
meta_error_trap_push (display);
|
meta_error_trap_push (display);
|
||||||
paint_all (screen, info->all_damage);
|
paint_all (screen, info->all_damage);
|
||||||
@ -1436,7 +1466,7 @@ add_damage (MetaScreen *screen,
|
|||||||
|
|
||||||
/* dump_xserver_region ("add_damage", display, damage); */
|
/* dump_xserver_region ("add_damage", display, damage); */
|
||||||
|
|
||||||
if (info->all_damage)
|
if (info != NULL && info->all_damage)
|
||||||
{
|
{
|
||||||
XFixesUnionRegion (xdisplay, info->all_damage, info->all_damage, damage);
|
XFixesUnionRegion (xdisplay, info->all_damage, info->all_damage, damage);
|
||||||
XFixesDestroyRegion (xdisplay, damage);
|
XFixesDestroyRegion (xdisplay, damage);
|
||||||
@ -1579,7 +1609,7 @@ free_win (MetaCompWindow *cw,
|
|||||||
|
|
||||||
/* The window may not have been added to the list in this case,
|
/* The window may not have been added to the list in this case,
|
||||||
but we can check anyway */
|
but we can check anyway */
|
||||||
if (cw->type == META_COMP_WINDOW_DOCK)
|
if (info!=NULL && cw->type == META_COMP_WINDOW_DOCK)
|
||||||
info->dock_windows = g_slist_remove (info->dock_windows, cw);
|
info->dock_windows = g_slist_remove (info->dock_windows, cw);
|
||||||
|
|
||||||
g_free (cw);
|
g_free (cw);
|
||||||
@ -1626,7 +1656,7 @@ unmap_win (MetaDisplay *display,
|
|||||||
MetaCompWindow *cw = find_window_for_screen (screen, id);
|
MetaCompWindow *cw = find_window_for_screen (screen, id);
|
||||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||||
|
|
||||||
if (cw == NULL)
|
if (cw == NULL || info == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1878,8 +1908,11 @@ destroy_win (MetaDisplay *display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
info = meta_screen_get_compositor_data (screen);
|
info = meta_screen_get_compositor_data (screen);
|
||||||
info->windows = g_list_remove (info->windows, (gconstpointer) cw);
|
if (info != NULL)
|
||||||
g_hash_table_remove (info->windows_by_xid, (gpointer) xwindow);
|
{
|
||||||
|
info->windows = g_list_remove (info->windows, (gconstpointer) cw);
|
||||||
|
g_hash_table_remove (info->windows_by_xid, (gpointer) xwindow);
|
||||||
|
}
|
||||||
|
|
||||||
free_win (cw, TRUE);
|
free_win (cw, TRUE);
|
||||||
}
|
}
|
||||||
@ -1896,6 +1929,11 @@ restack_win (MetaCompWindow *cw,
|
|||||||
screen = cw->screen;
|
screen = cw->screen;
|
||||||
info = meta_screen_get_compositor_data (screen);
|
info = meta_screen_get_compositor_data (screen);
|
||||||
|
|
||||||
|
if (info == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sibling = g_list_find (info->windows, (gconstpointer) cw);
|
sibling = g_list_find (info->windows, (gconstpointer) cw);
|
||||||
next = g_list_next (sibling);
|
next = g_list_next (sibling);
|
||||||
previous_above = None;
|
previous_above = None;
|
||||||
@ -2045,7 +2083,10 @@ resize_win (MetaCompWindow *cw,
|
|||||||
dump_xserver_region ("resize_win", display, damage);
|
dump_xserver_region ("resize_win", display, damage);
|
||||||
add_damage (screen, damage);
|
add_damage (screen, damage);
|
||||||
|
|
||||||
info->clip_changed = TRUE;
|
if (info != NULL)
|
||||||
|
{
|
||||||
|
info->clip_changed = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* event processors must all be called with an error trap in place */
|
/* event processors must all be called with an error trap in place */
|
||||||
@ -2075,7 +2116,10 @@ process_circulate_notify (MetaCompositorXRender *compositor,
|
|||||||
above = None;
|
above = None;
|
||||||
restack_win (cw, above);
|
restack_win (cw, above);
|
||||||
|
|
||||||
info->clip_changed = TRUE;
|
if (info != NULL)
|
||||||
|
{
|
||||||
|
info->clip_changed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_IDLE_REPAINT
|
#ifdef USE_IDLE_REPAINT
|
||||||
add_repair (compositor->display);
|
add_repair (compositor->display);
|
||||||
@ -2133,7 +2177,7 @@ process_configure_notify (MetaCompositorXRender *compositor,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
info = meta_screen_get_compositor_data (screen);
|
info = meta_screen_get_compositor_data (screen);
|
||||||
if (info->root_buffer)
|
if (info != NULL && info->root_buffer)
|
||||||
{
|
{
|
||||||
XRenderFreePicture (xdisplay, info->root_buffer);
|
XRenderFreePicture (xdisplay, info->root_buffer);
|
||||||
info->root_buffer = None;
|
info->root_buffer = None;
|
||||||
@ -2167,7 +2211,7 @@ process_property_notify (MetaCompositorXRender *compositor,
|
|||||||
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||||
Window xroot = meta_screen_get_xroot (screen);
|
Window xroot = meta_screen_get_xroot (screen);
|
||||||
|
|
||||||
if (info->root_tile)
|
if (info != NULL && info->root_tile)
|
||||||
{
|
{
|
||||||
XClearArea (xdisplay, xroot, 0, 0, 0, 0, TRUE);
|
XClearArea (xdisplay, xroot, 0, 0, 0, 0, TRUE);
|
||||||
XRenderFreePicture (xdisplay, info->root_tile);
|
XRenderFreePicture (xdisplay, info->root_tile);
|
||||||
@ -2809,8 +2853,8 @@ xrender_set_active_window (MetaCompositor *compositor,
|
|||||||
MetaDisplay *display;
|
MetaDisplay *display;
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
MetaCompWindow *old_focus = NULL, *new_focus = NULL;
|
MetaCompWindow *old_focus = NULL, *new_focus = NULL;
|
||||||
MetaCompScreen *info;
|
MetaCompScreen *info = NULL;
|
||||||
MetaWindow *old_focus_win;
|
MetaWindow *old_focus_win = NULL;
|
||||||
|
|
||||||
if (compositor == NULL)
|
if (compositor == NULL)
|
||||||
return;
|
return;
|
||||||
@ -2818,7 +2862,11 @@ xrender_set_active_window (MetaCompositor *compositor,
|
|||||||
display = xrc->display;
|
display = xrc->display;
|
||||||
xdisplay = meta_display_get_xdisplay (display);
|
xdisplay = meta_display_get_xdisplay (display);
|
||||||
info = meta_screen_get_compositor_data (screen);
|
info = meta_screen_get_compositor_data (screen);
|
||||||
old_focus_win = info->focus_window;
|
|
||||||
|
if (info != NULL)
|
||||||
|
{
|
||||||
|
old_focus_win = info->focus_window;
|
||||||
|
}
|
||||||
|
|
||||||
if (old_focus_win)
|
if (old_focus_win)
|
||||||
{
|
{
|
||||||
@ -2837,7 +2885,11 @@ xrender_set_active_window (MetaCompositor *compositor,
|
|||||||
meta_window_get_xwindow (window));
|
meta_window_get_xwindow (window));
|
||||||
}
|
}
|
||||||
|
|
||||||
info->focus_window = window;
|
if (info != NULL)
|
||||||
|
{
|
||||||
|
info->focus_window = window;
|
||||||
|
}
|
||||||
|
|
||||||
if (old_focus)
|
if (old_focus)
|
||||||
{
|
{
|
||||||
XserverRegion damage;
|
XserverRegion damage;
|
||||||
@ -2877,8 +2929,11 @@ xrender_set_active_window (MetaCompositor *compositor,
|
|||||||
|
|
||||||
dump_xserver_region ("resize_win", display, damage);
|
dump_xserver_region ("resize_win", display, damage);
|
||||||
add_damage (screen, damage);
|
add_damage (screen, damage);
|
||||||
|
|
||||||
info->clip_changed = TRUE;
|
if (info != NULL)
|
||||||
|
{
|
||||||
|
info->clip_changed = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2919,7 +2974,10 @@ xrender_set_active_window (MetaCompositor *compositor,
|
|||||||
dump_xserver_region ("resize_win", display, damage);
|
dump_xserver_region ("resize_win", display, damage);
|
||||||
add_damage (screen, damage);
|
add_damage (screen, damage);
|
||||||
|
|
||||||
info->clip_changed = TRUE;
|
if (info != NULL)
|
||||||
|
{
|
||||||
|
info->clip_changed = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_IDLE_REPAINT
|
#ifdef USE_IDLE_REPAINT
|
||||||
add_repair (display);
|
add_repair (display);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user