Skip to content

Commit

Permalink
XCB: Check screen size in boilerplate
Browse files Browse the repository at this point in the history
Trying to create a window for drawing that is larger than the available screen
space is a bad idea. When the test finishes and tries to grab the resulting
image from the X server, the window's area that is outside of the screen will
have undefined content.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
  • Loading branch information
Uli Schlachter authored and Chris Wilson committed Nov 7, 2010
1 parent daaef05 commit 6383e14
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions boilerplate/cairo-boilerplate-xcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ _cairo_boilerplate_xcb_create_window (const char *name,
xtc->surface = NULL;

s = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
if (width > s->width_in_pixels || height > s->height_in_pixels) {
xcb_disconnect (c);
free (xtc);
return NULL;
}

xtc->is_pixmap = FALSE;
xtc->drawable = xcb_generate_id (c);
cookie = xcb_create_window_checked (c,
Expand Down Expand Up @@ -319,6 +325,12 @@ _cairo_boilerplate_xcb_create_window_db (const char *name,
xtc->surface = NULL;

s = xcb_setup_roots_iterator (xcb_get_setup (c)).data;
if (width > s->width_in_pixels || height > s->height_in_pixels) {
xcb_disconnect (c);
free (xtc);
return NULL;
}

xtc->is_pixmap = FALSE;
xtc->drawable = xcb_generate_id (c);
cookie = xcb_create_window_checked (c,
Expand Down

0 comments on commit 6383e14

Please sign in to comment.