]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
mdev: Fix mingw build by adding a check for non-NULL pointer
authorErik Skultety <eskultet@redhat.com>
Thu, 4 May 2017 09:26:10 +0000 (11:26 +0200)
committerErik Skultety <eskultet@redhat.com>
Thu, 4 May 2017 11:23:09 +0000 (13:23 +0200)
This patch fixes the following MinGW error (although actually being a
false positive):

../../src/util/virmdev.c: In function 'virMediatedDeviceListMarkDevices':
../../src/util/virmdev.c:453:21: error: potential null pointer
dereference [-Werror=null-dereference]
          const char *mdev_path = mdev->path;
                      ^~~~~~~~~

Signed-off-by: Erik Skultety <eskultet@redhat.com>
src/util/virmdev.c

index c861d21c9e9a17f2a1c105f36394b7a4b7f2ec32..174f48cb3018c5b6426baa7ece0c79a6afac5f69 100644 (file)
@@ -449,9 +449,13 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
 
     virObjectLock(dst);
     for (i = 0; i < count; i++) {
+        const char *mdev_path = NULL;
         virMediatedDevicePtr mdev = virMediatedDeviceListGet(src, i);
-        const char *mdev_path = mdev->path;
 
+        if (!mdev)
+            goto cleanup;
+
+        mdev_path = mdev->path;
         if (virMediatedDeviceIsUsed(mdev, dst) ||
             virMediatedDeviceSetUsedBy(mdev, drvname, domname) < 0)
             goto cleanup;