summaryrefslogtreecommitdiff
path: root/slstatus.c
diff options
context:
space:
mode:
authorAaron Marcher <me@drkhsh.at>2017-08-11 14:33:02 +0200
committerAaron Marcher <me@drkhsh.at>2017-08-11 14:33:02 +0200
commit6f011743921db04e5513df45c5ac4b2c752d52de (patch)
treeb42c371f2d13c159b611949c7aca7aca6bdf031a /slstatus.c
parent1814061396ef5855e2d1815665fc32e0902ccbe9 (diff)
Fixed possible NULL-deref and removed unnecessary XOpenDisplay()
- 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.
Diffstat (limited to 'slstatus.c')
-rw-r--r--slstatus.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/slstatus.c b/slstatus.c
index 596d6a6..47bd4c9 100644
--- a/slstatus.c
+++ b/slstatus.c
@@ -380,10 +380,9 @@ kernel_release(void)
static const char *
keyboard_indicators(void)
{
- Display *dpy = XOpenDisplay(NULL);
XKeyboardState state;
+
XGetKeyboardControl(dpy, &state);
- XCloseDisplay(dpy);
switch (state.led_mask) {
case 1:
@@ -879,6 +878,10 @@ main(int argc, char *argv[])
if (!sflag) {
dpy = XOpenDisplay(NULL);
+ if (!dpy) {
+ fprintf(stderr, "slstatus: cannot open display");
+ exit(1);
+ }
}
setlocale(LC_ALL, "");