Richard W.M. Jones
2023-Feb-16 15:23 UTC
[Libguestfs] [PATCH] python: Avoid leaking py_array along error paths
See-also: https://listman.redhat.com/archives/libguestfs/2023-February/030730.html Fixes: commit 6ef5837e2d8c5d4d83eff51c0201eb2e08f719de Thanks: Laszlo Ersek --- python/handle.c | 1 + 1 file changed, 1 insertion(+) diff --git a/python/handle.c b/python/handle.c index bf639b5789..717eee83ed 100644 --- a/python/handle.c +++ b/python/handle.c @@ -136,6 +136,7 @@ guestfs_int_py_event_callback_wrapper (guestfs_h *g, buf, buf_len, py_array); if (args == NULL) { PyErr_PrintEx (0); + Py_DECREF (py_array); goto out; } -- 2.39.0
Eric Blake
2023-Feb-17 16:54 UTC
[Libguestfs] [PATCH] python: Avoid leaking py_array along error paths
On Thu, Feb 16, 2023 at 03:23:51PM +0000, Richard W.M. Jones wrote:> See-also: https://listman.redhat.com/archives/libguestfs/2023-February/030730.html > Fixes: commit 6ef5837e2d8c5d4d83eff51c0201eb2e08f719de > Thanks: Laszlo Ersek > --- > python/handle.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/python/handle.c b/python/handle.c > index bf639b5789..717eee83ed 100644 > --- a/python/handle.c > +++ b/python/handle.c > @@ -136,6 +136,7 @@ guestfs_int_py_event_callback_wrapper (guestfs_h *g, > buf, buf_len, py_array); > if (args == NULL) { > PyErr_PrintEx (0); > + Py_DECREF (py_array); > goto out; > }See my response in the other thread. You are also leaking args, which is not fixed here. I think the correct sequence is: py_array = ... args = Py_BuildValue("...O", py_array); Py_DECREF (py_array); if (args == NULL) { PyErr_PrintEx (0); goto out; } ... out: Py_DECREF (args); -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Possibly Parallel Threads
- [PATCH] python: Avoid leaking py_array along error paths
- [PATCH v3 0/2] python: Avoid leaking py_array and py_args in event callbacks
- [PATCH 1/2] python: Avoid crash if callback parameters cannot be built
- python: Avoid leaking py_array and py_args in event callbacks
- [PATCH 1/2] python: Avoid crash if callback parameters cannot be built