]> git.sur5r.net Git - i3/i3status/commitdiff
Fix potential memory leak on Linux
authorOlivier Gayot <olivier.gayot@sigexec.com>
Wed, 20 Jun 2018 09:58:10 +0000 (11:58 +0200)
committerOlivier Gayot <olivier.gayot@sigexec.com>
Wed, 20 Jun 2018 12:20:17 +0000 (14:20 +0200)
The function slurp_all_batteries(), on Linux, allocates memory
dynamically

Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
src/print_battery_info.c

index 7a462f7fcf29dd0148d19f3a3189e09f24b5bc48..72c2d6f4af0f7e9621c83910b0dc3e68edf0b7e8 100644 (file)
@@ -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);