From: Richard W.M. Jones Date: Thu, 24 Nov 2011 14:06:31 +0000 (+0000) Subject: virt-alignment-scan: Add checks for when API calls return NULL. X-Git-Tag: 1.15.6~11 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=7b192f5a672197ad67ac23501e420c674aa2f3a9;p=libguestfs.git virt-alignment-scan: Add checks for when API calls return NULL. In particular, virt-alignment-scan -a /dev/null would segfault because of an error returned by parted. --- diff --git a/align/scan.c b/align/scan.c index 529add5..7b4631a 100644 --- a/align/scan.c +++ b/align/scan.c @@ -228,9 +228,13 @@ scan (void) struct guestfs_partition_list *parts; devices = guestfs_list_devices (g); + if (devices == NULL) + exit (EXIT_FAILURE); for (i = 0; devices[i] != NULL; ++i) { parts = guestfs_part_list (g, devices[i]); + if (parts == NULL) + exit (EXIT_FAILURE); /* Canonicalize the name of the device for printing. */ if (STRPREFIX (devices[i], "/dev/") &&