xfreerdp: fix crash with /monitor-list
authorBernhard Miklautz <bernhard.miklautz@thincast.com>
Thu, 15 Jan 2015 20:38:52 +0000 (21:38 +0100)
committerBernhard Miklautz <bernhard.miklautz@thincast.com>
Thu, 15 Jan 2015 23:10:36 +0000 (00:10 +0100)
Catch the case when /monitor-list was used but the X display couldn't
be opened or wasn't available.

client/X11/xf_monitor.c

index 443a740..59fa850 100644 (file)
@@ -50,6 +50,11 @@ int xf_list_monitors(xfContext* xfc)
        XineramaScreenInfo* screen = NULL;
 
        display = XOpenDisplay(NULL);
+       if (!display)
+       {
+               WLog_ERR(TAG, "failed to open X display");
+               return -1;
+       }
 
        if (XineramaQueryExtension(display, &ignored, &ignored2))
        {
@@ -76,6 +81,11 @@ int xf_list_monitors(xfContext* xfc)
 
        display = XOpenDisplay(NULL);
 
+       if(!display)
+       {
+               WLog_ERR(TAG, "failed to open X display");
+               return -1;
+       }
        screen = ScreenOfDisplay(display, DefaultScreen(display));
        WLog_DBG(TAG, "      * [0] %dx%d\t+%d+%d", WidthOfScreen(screen), HeightOfScreen(screen), 0, 0);
        XCloseDisplay(display);