[libvirt] [PATCH 10/10] qemu_capabilities: Resolve Coverity NULL_RETURNS

John Ferlan jferlan at redhat.com
Wed Aug 27 13:51:33 UTC 2014


Adjust the initialization of qemuCaps() to check for a NULL before
attempting to dereference like other callers/users do.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/qemu/qemu_capabilities.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 410086b..ce899f2 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3349,10 +3349,13 @@ virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
                                        uid_t runUid,
                                        gid_t runGid)
 {
-    virQEMUCapsPtr qemuCaps = virQEMUCapsNew();
+    virQEMUCapsPtr qemuCaps;
     struct stat sb;
     int rv;
 
+    if (!(qemuCaps = virQEMUCapsNew()))
+        goto error;
+
     if (VIR_STRDUP(qemuCaps->binary, binary) < 0)
         goto error;
 
-- 
1.9.3




More information about the libvir-list mailing list