[PATCH xorg-gtest 2/2] XCloseDisplay(3) cannot handle NULL

Peter Hutterer peter.hutterer at who-t.net
Thu May 24 18:57:20 PDT 2012


If the display failed to start, tearing it down with a NULL pointer causes a
segfault.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/test.cpp |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/test.cpp b/src/test.cpp
index c2df5a7..f016f06 100644
--- a/src/test.cpp
+++ b/src/test.cpp
@@ -48,7 +48,8 @@ void xorg::testing::Test::SetUp() {
 }
 
 void xorg::testing::Test::TearDown() {
-  XCloseDisplay(d_->display);
+  if (d_->display)
+    XCloseDisplay(d_->display);
   d_->display = NULL;
 }
 
-- 
1.7.10.1



More information about the xorg-devel mailing list