<p dir="ltr">Looks good to me!</p>
<p dir="ltr">Reviewed-by: Jamey Sharp <<a href="mailto:jamey@minilop.net">jamey@minilop.net</a>></p>
<div class="gmail_quote">On Oct 5, 2013 5:05 AM, "Egbert Eich" <<a href="mailto:eich@freedesktop.org">eich@freedesktop.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: Radek Doulik <<a href="mailto:rodo@novell.com">rodo@novell.com</a>><br>
<br>
When an Xnest instance is not viewable it will crash when a client in<br>
that instance calls GetImage. This is because the Xnest server will<br>
itself receives a BadMatch error.<br>
This patch ignores the error. The application which has requested the<br>
image will receive garbage - this however is fully legal according<br>
to the specs as obscured areas will always contain garbage if there<br>
isn't some sort of backing store as discussed in<br>
<a href="https://bugs.freedesktop.org/show_bug.cgi?id=9488" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=9488</a><br>
The applied patch is a version from Dadek Doulik.<br>
<br>
v2: Call XSync() before changing error handlers as suggested by<br>
Daniel Stone <<a href="mailto:daniel@fooishbar.org">daniel@fooishbar.org</a>>.<br>
v3: Don't call Xsync before restoring error handler as any errors<br>
generated by XGetImage() should be processed when this call<br>
returns as suggested by Jamey Sharp <<a href="mailto:jamey@minilop.net">jamey@minilop.net</a>><br>
<br>
Signed-off-by: Egbert Eich <<a href="mailto:eich@freedesktop.org">eich@freedesktop.org</a>><br>
---<br>
hw/xnest/GCOps.c | 13 +++++++++++++<br>
1 file changed, 13 insertions(+)<br>
<br>
diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c<br>
index e26a136..d00511d 100644<br>
--- a/hw/xnest/GCOps.c<br>
+++ b/hw/xnest/GCOps.c<br>
@@ -94,15 +94,28 @@ xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,<br>
}<br>
}<br>
<br>
+static int<br>
+xnestIgnoreErrorHandler (Display *display,<br>
+ XErrorEvent *event)<br>
+{<br>
+ return False; /* return value is ignored */<br>
+}<br>
+<br>
void<br>
xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,<br>
unsigned int format, unsigned long planeMask, char *pImage)<br>
{<br>
XImage *ximage;<br>
int length;<br>
+ int (*old_handler)(Display*, XErrorEvent*);<br>
+<br>
+ /* we may get BadMatch error when xnest window is minimized */<br>
+ XSync(xnestDisplay, False);<br>
+ old_handler = XSetErrorHandler (xnestIgnoreErrorHandler);<br>
<br>
ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable),<br>
x, y, w, h, planeMask, format);<br>
+ XSetErrorHandler(old_handler);<br>
<br>
if (ximage) {<br>
length = ximage->bytes_per_line * ximage->height;<br>
--<br>
1.8.1.4<br>
<br>
</blockquote></div>