[libvirt] [libvirt-python PATCH 1/1] virDomainBlockCopy: initialize flags to 0

Peter Krempa pkrempa at redhat.com
Wed Oct 22 12:47:41 UTC 2014


On 10/22/14 13:53, Pavel Hrdina wrote:
> An optional argument if not passed isn't modified by the
> PyArg_ParseTuple function.
> 
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
> 
> Sigh :/, pushed as trivial
> 
>  libvirt-override.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libvirt-override.c b/libvirt-override.c
> index a461eda..a53b46f 100644
> --- a/libvirt-override.c
> +++ b/libvirt-override.c
> @@ -8171,7 +8171,7 @@ libvirt_virDomainBlockCopy(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
>      char *destxml = NULL;
>      virTypedParameterPtr params = NULL;
>      int nparams = 0;
> -    unsigned int flags;
> +    unsigned int flags = 0;
>      int c_retval;
>  
>      if (!PyArg_ParseTuple(args, (char *) "Ozz|OI:virDomainBlockCopy",
> 

Actually as the python wrapper function generated by generator py looks like:

    def blockCopy(self, disk, destxml, params=None, flags=0):
        """Copy the guest-visible contents of a disk image to a new file described by destxml """
        ret = libvirtmod.virDomainBlockCopy(self._o, disk, destxml, params, flags)
        if ret == -1: raise libvirtError ('virDomainBlockCopy() failed', dom=self)
        return ret

it is guaranteed that both params and flags are initialized. Thus this patch isnt necessary.

If it wasn't initialized, the code would have a second problem as PyDict_Check
unconditionally dereferences the passed object.

Peter


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141022/c58a11d1/attachment-0001.sig>


More information about the libvir-list mailing list