OSDN Git Service

linux: Fix a crash in populate_devices
authorAdam Jackson <ajax@redhat.com>
Wed, 3 Aug 2011 22:35:11 +0000 (18:35 -0400)
committerAdam Jackson <ajax@redhat.com>
Wed, 3 Aug 2011 22:35:11 +0000 (18:35 -0400)
If scandir returns -1, the 'devices' array won't be initialized, and
attempting to free() it will crash.

Signed-off-by: Adam Jackson <ajax@redhat.com>
src/linux_sysfs.c

index bbd4dfa..2085ffb 100644 (file)
@@ -122,7 +122,7 @@ scan_sys_pci_filter( const struct dirent * d )
 int
 populate_entries( struct pci_system * p )
 {
-    struct dirent ** devices;
+    struct dirent ** devices = NULL;
     int n;
     int i;
     int err = 0;