Free return value from scandir instead of leaking it.
authorKeith Packard <keithp@keithp.com>
Fri, 18 Sep 2009 00:38:56 +0000 (17:38 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 18 Sep 2009 00:40:05 +0000 (17:40 -0700)
Scandir is defined to return pointers to malloc'd storage, so make
sure that memory is nicely freed.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/linux_sysfs.c

index 02fbd13..85095b3 100644 (file)
@@ -213,6 +213,10 @@ populate_entries( struct pci_system * p )
        }
     }
 
+    for (i = 0; i < n; i++)
+       free(devices[i]);
+    free(devices);
+
     if (err) {
        free(p->devices);
        p->devices = NULL;