Fix potential memory leak on Linux
The function slurp_all_batteries(), on Linux, allocates memory dynamically Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
This commit is contained in:
parent
c64195d147
commit
445b1925e3
@ -450,8 +450,11 @@ 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);
|
||||
|
Loading…
Reference in New Issue
Block a user