summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadek Doulik <rodo@novell.com>2013-08-13 08:45:47 +0200
committerAdam Jackson <ajax@redhat.com>2013-09-10 13:26:26 -0400
commit65fca558848acd907483d3c85c7cd4db5560f1b4 (patch)
tree91757ec6a6e05a6a24f2b81cf934548e3087eac9
parentb902c8abb6d03e68c93e13881a350523b5ac900c (diff)
xnest: Ignore GetImage() error in xnestGetImage()
When an Xnest instance is not viewable it will crash when a client in that instance calls GetImage. This is because the Xnest server will itself receives a BadMatch error. This patch ignores the error. The application which has requested the image will receive garbage - this however is fully legal according to the specs as obscured areas will always contain garbage if there isn't some sort of backing store as discussed in https://bugs.freedesktop.org/show_bug.cgi?id=9488 The applied patch is a version from Dadek Doulik. v2: Call XSync() before changing error handlers as suggested by Daniel Stone <daniel@fooishbar.org>. Reviewed-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Egbert Eich <eich@freedesktop.org>
-rw-r--r--hw/xnest/GCOps.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c
index e26a1363b..7b1956de0 100644
--- a/hw/xnest/GCOps.c
+++ b/hw/xnest/GCOps.c
@@ -94,15 +94,29 @@ xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
}
}
+static int
+xnestIgnoreErrorHandler (Display *display,
+ XErrorEvent *event)
+{
+ return False; /* return value is ignored */
+}
+
void
xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
unsigned int format, unsigned long planeMask, char *pImage)
{
XImage *ximage;
int length;
+ int (*old_handler)(Display*, XErrorEvent*);
+
+ /* we may get BadMatch error when xnest window is minimized */
+ XSync(xnestDisplay, False);
+ old_handler = XSetErrorHandler (xnestIgnoreErrorHandler);
ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable),
x, y, w, h, planeMask, format);
+ XSync(xnestDisplay, False);
+ XSetErrorHandler(old_handler);
if (ximage) {
length = ximage->bytes_per_line * ximage->height;