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

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



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


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