From 7c56b4c332c2bfadc851375b0d38b6991ea81a7a Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Fri, 17 Oct 2014 10:28:55 +0100 Subject: [PATCH] Check the return value from XShmAttach. --- vncviewer/X11PixelBuffer.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vncviewer/X11PixelBuffer.cxx b/vncviewer/X11PixelBuffer.cxx index f83aa5f4..a7794277 100644 --- a/vncviewer/X11PixelBuffer.cxx +++ b/vncviewer/X11PixelBuffer.cxx @@ -189,7 +189,11 @@ int X11PixelBuffer::setupShm() caughtError = false; old_handler = XSetErrorHandler(XShmAttachErrorHandler); - XShmAttach(fl_display, shminfo); + if (!XShmAttach(fl_display, shminfo)) { + XSetErrorHandler(old_handler); + goto free_shmaddr; + } + XSync(fl_display, False); XSetErrorHandler(old_handler); -- 2.39.5