
On Wed, May 02, 2012 at 10:51:32PM +0800, Osier Yang wrote:
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;
NACK, the correct fix is to remove teh NONNULL annotation from getPyVirTypedParameter() since it is perfectly acceptable to pass in NULL there & the code handles it fine. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|