diff options
author | Ingo Bürk <admin@airblader.de> | 2018-06-22 13:55:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-22 13:55:09 +0200 |
commit | 4d3344ab9cd68bad5faf4ed3dad185dfcacb1e3d (patch) | |
tree | 66846b5f6023291fda2d72fe523d4ee0614d2a1f /src/print_battery_info.c | |
parent | 64fd6e10478cabd0e2f9b554b71971a865c02d60 (diff) | |
parent | c221b4d331d46d07fe24afc78e4eeb021556d013 (diff) |
Merge pull request #290 from duskCoder/changes
Fix potential issues & avoid unnecessary instructions
Diffstat (limited to 'src/print_battery_info.c')
-rw-r--r-- | src/print_battery_info.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/print_battery_info.c b/src/print_battery_info.c index 7a462f7..04b5a25 100644 --- a/src/print_battery_info.c +++ b/src/print_battery_info.c @@ -450,14 +450,17 @@ static bool slurp_all_batteries(struct battery_info *batt_info, yajl_gen json_ge .present_rate = 0, .status = CS_UNKNOWN, }; - if (!slurp_battery_info(&batt_buf, json_gen, buffer, i, globbuf.gl_pathv[i], format_down)) + if (!slurp_battery_info(&batt_buf, json_gen, buffer, i, globbuf.gl_pathv[i], format_down)) { + globfree(&globbuf); + free(globpath); return false; + } is_found = true; add_battery_info(batt_info, &batt_buf); } + globfree(&globbuf); } - globfree(&globbuf); free(globpath); if (!is_found) { |