From 2c114ec2b506e32d54586110c710c78ef156e066 Mon Sep 17 00:00:00 2001 From: "Ali H. Fardan" Date: Sat, 12 Aug 2017 07:01:13 +0300 Subject: keyboard_indicators: fix segfault when -s is specified --- slstatus.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/slstatus.c b/slstatus.c index 47bd4c9..aa05cd1 100644 --- a/slstatus.c +++ b/slstatus.c @@ -380,9 +380,15 @@ kernel_release(void) static const char * keyboard_indicators(void) { + Display *dpy = XOpenDisplay(NULL); XKeyboardState state; + if (dpy == NULL) { + warnx("XOpenDisplay failed"); + return UNKNOWN_STR; + } XGetKeyboardControl(dpy, &state); + XCloseDisplay(dpy); switch (state.led_mask) { case 1: -- cgit v1.2.3