- Added a check for the return value of XOpenDisplay() in main().
This fixes a possible NULL-deref.
- Removed unnsecessary XOpenDisplay and XCloseDisplay from
keyboard_indicators(). The ones in main() are sufficent.
static const char *
keyboard_indicators(void)
{
- Display *dpy = XOpenDisplay(NULL);
XKeyboardState state;
+
XGetKeyboardControl(dpy, &state);
- XCloseDisplay(dpy);
switch (state.led_mask) {
case 1:
if (!sflag) {
dpy = XOpenDisplay(NULL);
+ if (!dpy) {
+ fprintf(stderr, "slstatus: cannot open display");
+ exit(1);
+ }
}
setlocale(LC_ALL, "");