tests/disks: Don't segfault if guestfs_list_devices returns an error.

Although it's highly unlikely in normal use, while testing device name
translation patches it did happen and caused the test to segfault
instead of exiting with an error.
This commit is contained in:
Richard W.M. Jones
2020-03-05 12:07:14 +00:00
parent 2639de38c1
commit eb17229c3e

View File

@@ -261,6 +261,8 @@ do_test (guestfs_h *g, size_t ndisks, bool just_add)
/* Check the disks were added. */
devices = guestfs_list_devices (g);
if (devices == NULL)
exit (EXIT_FAILURE);
n = guestfs_int_count_strings (devices);
if (n != ndisks) {
fprintf (stderr, "%s: incorrect number of devices returned by guestfs_list_devices:\n",