diff options
Diffstat (limited to 'bat_tray.c')
-rw-r--r-- | bat_tray.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -235,10 +235,15 @@ int get_battery_state() char state[1024]; FILE* fd = NULL; - if (!(fd = fopen(CHARGE_STATE_PATH, "r")) || - !fgets(state, sizeof(state), fd)) + if (!(fd = fopen(CHARGE_STATE_PATH, "r"))) return STATE_UNKNOWN; + if (!fgets(state, sizeof(state), fd)) + { + fclose(fd); + return STATE_UNKNOWN; + } + fclose(fd); chomp(state); |