[PATCH 1/6] qemumigrationcookiexmltest: Don't crash when parsing of status XML fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some sub-tests dereference 'data->vm' even when it is NULL.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/qemumigrationcookiexmltest.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tests/qemumigrationcookiexmltest.c b/tests/qemumigrationcookiexmltest.c
index 74302dc55f..5270e3a7e7 100644
--- a/tests/qemumigrationcookiexmltest.c
+++ b/tests/qemumigrationcookiexmltest.c
@@ -137,9 +137,17 @@ static int
 testQemuMigrationCookieParse(const void *opaque)
 {
     struct testQemuMigrationCookieData *data = (struct testQemuMigrationCookieData *) opaque;
-    qemuDomainObjPrivate *priv = data->vm->privateData;
+    qemuDomainObjPrivate *priv;
     g_auto(virBuffer) actual = VIR_BUFFER_INITIALIZER;

+    /* if the VM object parsing step failed there's nothing this test can do */
+    if (!data->vm) {
+        VIR_TEST_DEBUG("\nmissing VM object\n");
+        return -1;
+    }
+
+    priv = data->vm->privateData;
+
     if (!(data->cookie = qemuMigrationCookieParse(&driver,
                                                   data->vm,
                                                   data->vm->def,
@@ -314,6 +322,12 @@ testQemuMigrationCookieBlockDirtyBitmaps(const void *opaque)
         return -1;
     }

+    /* if the VM object parsing step failed there's nothing this test can do */
+    if (!data->vm) {
+        VIR_TEST_DEBUG("\nmissing VM object\n");
+        return -1;
+    }
+
     if (qemuMigrationCookieBlockDirtyBitmapsMatchDisks(data->vm->def,
                                                        data->cookie->blockDirtyBitmaps) < 0)
         return -1;
-- 
2.41.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux