From eb17229c3e1c842df3437556f0855194941da9cc Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 5 Mar 2020 12:07:14 +0000 Subject: [PATCH] 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. --- tests/disks/test-add-disks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/disks/test-add-disks.c b/tests/disks/test-add-disks.c index 73a497ebc..8204186b0 100644 --- a/tests/disks/test-add-disks.c +++ b/tests/disks/test-add-disks.c @@ -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",