Re: [PATCH] libvirt-python : PyObject memory leak

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

 



On 12/08/2017 12:33 AM, Peng Hao wrote:
> libvirt_virConnectDomainEventTunableCallback leak a PyObject
> 
> Signed-off-by: Peng Hao <peng.hao2@xxxxxxxxxx>
> Signed-off-by: Wang Yechao <wang.yechao255@xxxxxxxxxx>
> ---
>  libvirt-override.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libvirt-override.c b/libvirt-override.c
> index d746350..eab9b62 100644
> --- a/libvirt-override.c
> +++ b/libvirt-override.c
> @@ -6665,6 +6665,7 @@ libvirt_virConnectDomainEventTunableCallback(virConnectPtr conn ATTRIBUTE_UNUSED
>          Py_XDECREF(pyobj_dict);
>      } else {
>          Py_DECREF(pyobj_ret);
> +        Py_DECREF(pyobj_dict);
>          ret = 0;
>      }
>  
> 

I'd prefer just to have pyobj_dict freed outside of the if-else
statement:

diff --git c/libvirt-override.c w/libvirt-override.c
index d746350..78a7f08 100644
--- c/libvirt-override.c
+++ w/libvirt-override.c
@@ -6662,11 +6662,11 @@
libvirt_virConnectDomainEventTunableCallback(virConnectPtr conn
ATTRIBUTE_UNUSED
     if (!pyobj_ret) {
         DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
         PyErr_Print();
-        Py_XDECREF(pyobj_dict);
     } else {
         Py_DECREF(pyobj_ret);
         ret = 0;
     }
+    Py_XDECREF(pyobj_dict);

     LIBVIRT_RELEASE_THREAD_STATE;
     return ret;


Mind posting v2?

Michal

--
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]
  Powered by Linux