[PATCH 1/7] Coverity: Fix the forward_null error in Python binding codes

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

 



Related coverity log:

Error: FORWARD_NULL:
/builddir/build/BUILD/libvirt-0.9.10/python/libvirt-override.c:355:
assign_zero: Assigning: "params" = 0.
/builddir/build/BUILD/libvirt-0.9.10/python/libvirt-override.c:458:
var_deref_model: Passing null variable "params" to function
"getPyVirTypedParameter", which dereferences it. (The dereference is assumed on
the basis of the 'nonnull' parameter attribute.)
---
 python/libvirt-override.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 56f96ba..7fd7cb7 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -435,14 +435,14 @@ libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
             goto error;
         }
 
+        if (VIR_ALLOC_N(params, nparams) < 0) {
+            error = PyErr_NoMemory();
+            goto error;
+        }
+
         if (nparams) {
             sumparams = nparams;
 
-            if (VIR_ALLOC_N(params, nparams) < 0) {
-                error = PyErr_NoMemory();
-                goto error;
-            }
-
             LIBVIRT_BEGIN_ALLOW_THREADS;
             i_retval = virDomainGetCPUStats(domain, params, nparams, -1, 1, flags);
             LIBVIRT_END_ALLOW_THREADS;
-- 
1.7.7.3

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