Skip to content

Commit 086f872

Browse files
hyongtao-codethunder-coding
authored andcommitted
pythongh-143145: Fix possible reference leak in ctypes _build_result() (pythonGH-143131)
The result tuple was leaked if __ctypes_from_outparam__() failed for any item. Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
1 parent 1c7bcf8 commit 086f872

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

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)