[PATCH 3/9] tests: Need to check return of virGetLastError

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

 



Cannot assume virGetLastError returns non-NULL value - modify the code to
fetch err and check if err && err->code

Found by Coverity

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 tests/qemuhelptest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 8aac997..7c8b841 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -60,7 +60,9 @@ static int testHelpStrParsing(const void *data)
 
     if (virQEMUCapsParseHelpStr("QEMU", help, flags,
                                 &version, &is_kvm, &kvm_version, false, NULL) == -1) {
-        if (info->error && virGetLastError()->code == info->error)
+        virErrorPtr err = virGetLastError();
+
+        if (info->error && err && err->code == info->error)
             ret = 0;
         goto cleanup;
     }
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]