[Pkg-wmaker-commits] [wmbattery] 226/241: wmbattery: Properly free malloced memory.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:38:04 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmbattery.

commit 9f7be30fc6a2541a89e129b82d41c6f8d2c0d71a
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Wed May 13 23:38:56 2015 -0500

    wmbattery: Properly free malloced memory.
    
    Fixes memory leak found by cppcheck.
---
 acpi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/acpi.c b/acpi.c
index 1e837d2..dc2f3bc 100644
--- a/acpi.c
+++ b/acpi.c
@@ -188,8 +188,10 @@ int find_items(char *itemname, char infoarray[ACPI_MAXITEM][128],
 	sprintf(pathname, SYSFS_PATH);
 
 	dir = opendir(pathname);
-	if (dir == NULL)
+	if (dir == NULL) {
+		free(devices);
 		return 0;
+	}
 	while ((ent = readdir(dir))) {
 		char filename[128];
 		char buf[1024];
@@ -224,9 +226,9 @@ int find_items(char *itemname, char infoarray[ACPI_MAXITEM][128],
 			acpi_labels[label_info]);
 		snprintf(statusarray[i], sizeof(statusarray[i]), SYSFS_PATH "/%s/%s", devices[i],
 			acpi_labels[label_status]);
-		free(devices[i]);
 	}
 
+	free(devices);
 	return num_devices;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbattery.git



More information about the Pkg-wmaker-commits mailing list