Skip to content

Commit 579c5b4

Browse files
gh-143145: Fix possible reference leak in ctypes _build_result() (GH-143131)
The result tuple was leaked if __ctypes_from_outparam__() failed for any item. Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
1 parent 8d46f96 commit 579c5b4

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a possible reference leak in ctypes when constructing results with multiple output parameters on error.

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4557,6 +4557,7 @@ _build_result(PyObject *result, PyObject *callargs,
45574557
v = PyTuple_GET_ITEM(callargs, i);
45584558
v = PyObject_CallMethodNoArgs(v, &_Py_ID(__ctypes_from_outparam__));
45594559
if (v == NULL || numretvals == 1) {
4560+
Py_XDECREF(tup);
45604561
Py_DECREF(callargs);
45614562
return v;
45624563
}

0 commit comments

Comments
 (0)