Commit: e34ab8280f67a18e5f2ce49a55c666efee1f2635
Parent: 6869609bc46f9607ababd16ace54c6db84f379b3
Author: Fabian Foerg
Date: Tue, 31 May 2016 12:47:19 +0200
Fix crash when DISPLAY env variable is set to an invalid value
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/sct.c b/sct.c
@@ -19,6 +19,7 @@
*/
#include <math.h>
+#include <stdio.h>
#include <stdlib.h>
#include <X11/Xatom.h>
@@ -87,6 +88,11 @@ int
main(int argc, char **argv)
{
Display *dpy = XOpenDisplay(NULL);
+ if (!dpy) {
+ perror("XOpenDisplay(NULL) failed");
+ fprintf(stderr, "Make sure DISPLAY is set correctly.\n");
+ return EXIT_FAILURE;
+ }
int screens = XScreenCount(dpy);
int temp = 6500;