From: Richard W.M. Jones Date: Wed, 8 Jun 2011 21:01:41 +0000 (+0100) Subject: Coverity: Avoid calling sort_strings (NULL, 0) on empty list. X-Git-Tag: 1.10.4~13 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=d19ed53dc8c62fa2b995890bf015c66e758a429a;p=libguestfs.git Coverity: Avoid calling sort_strings (NULL, 0) on empty list. (cherry picked from commit 3ed8d5122026f37dd96cc7e8503c4f3ecf0afbb7) --- diff --git a/daemon/devsparts.c b/daemon/devsparts.c index 1781def..c8f0256 100644 --- a/daemon/devsparts.c +++ b/daemon/devsparts.c @@ -105,8 +105,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) {