X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fdevsparts.c;h=52a6d304d5afb6a1e45c33eb9ab25d723b59a46f;hb=f15961911316460f7d45342d63c2d784a483f0d1;hp=1781def3feb9ac876011328a490def77d2ff7b63;hpb=ffd4820ffe953b0583e3a9357e37d74bed3a2320;p=libguestfs.git diff --git a/daemon/devsparts.c b/daemon/devsparts.c index 1781def..52a6d30 100644 --- a/daemon/devsparts.c +++ b/daemon/devsparts.c @@ -89,6 +89,7 @@ foreach_block_device (block_dev_func_t func) if(0 != errno) { reply_with_perror ("readdir: /sys/block"); free_stringslen(r, size); + closedir (dir); return NULL; } @@ -105,8 +106,9 @@ foreach_block_device (block_dev_func_t func) return NULL; } - /* Sort the devices */ - sort_strings (r, size); + /* Sort the devices. Note that r might be NULL if there are no devices. */ + if (r != NULL) + sort_strings (r, size); /* NULL terminate the list */ if (add_string (&r, &size, &alloc, NULL) == -1) { @@ -174,6 +176,7 @@ add_partitions(const char *device, if(0 != errno) { reply_with_perror ("readdir: %s", devdir); free_stringslen(*r, *size); + closedir (dir); return -1; }