wmbattery: Properly free malloced memory.
Fixes memory leak found by cppcheck.
This commit is contained in:
parent
7a04d6805b
commit
29e50127b6
|
@ -188,8 +188,10 @@ int find_items(char *itemname, char infoarray[ACPI_MAXITEM][128],
|
||||||
sprintf(pathname, SYSFS_PATH);
|
sprintf(pathname, SYSFS_PATH);
|
||||||
|
|
||||||
dir = opendir(pathname);
|
dir = opendir(pathname);
|
||||||
if (dir == NULL)
|
if (dir == NULL) {
|
||||||
|
free(devices);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
while ((ent = readdir(dir))) {
|
while ((ent = readdir(dir))) {
|
||||||
char filename[128];
|
char filename[128];
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
@ -224,9 +226,9 @@ int find_items(char *itemname, char infoarray[ACPI_MAXITEM][128],
|
||||||
acpi_labels[label_info]);
|
acpi_labels[label_info]);
|
||||||
snprintf(statusarray[i], sizeof(statusarray[i]), SYSFS_PATH "/%s/%s", devices[i],
|
snprintf(statusarray[i], sizeof(statusarray[i]), SYSFS_PATH "/%s/%s", devices[i],
|
||||||
acpi_labels[label_status]);
|
acpi_labels[label_status]);
|
||||||
free(devices[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(devices);
|
||||||
return num_devices;
|
return num_devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue