From 9e81c5b737cda9dc539b2cf497c20ac48ddb91ac Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 25 Apr 2012 20:41:16 +0100 Subject: xlib: Allow applications to create 0x0 surfaces Although 0x0 is not a legimate surface size, we do allow applications the flexibility to reset the size before drawing. As we previously never checked the size against minimum legal constraints, applications expect to be able to create seemingly illegal surfaces, and so we must continue to provide backwards compatibility. Many thanks to Pauli Nieminen for trawling through the protocol traces, diving into the depths of libreoffice and identifying the regression. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=49118 (presentation mode in loimpress is blank). Reported-by: Eric Valette Signed-off-by: Chris Wilson --- src/cairo-xlib-surface.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index 0645da684..95fadaca6 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -1613,7 +1613,14 @@ _cairo_xlib_screen_from_visual (Display *dpy, Visual *visual) static cairo_bool_t valid_size (int width, int height) { - return width > 0 && width <= XLIB_COORD_MAX && height > 0 && height <= XLIB_COORD_MAX; + /* Note: the minimum surface size allowed in the X protocol is 1x1. + * However, as we historically did not check the minimum size we + * allowed applications to lie and set the correct size later (one hopes). + * To preserve compatability we must allow applications to use + * 0x0 surfaces. + */ + return (width >= 0 && width <= XLIB_COORD_MAX && + height >= 0 && height <= XLIB_COORD_MAX); } /** -- cgit v1.2.3