diff options
author | Kirill Podoprigora <kirill.bast9@mail.ru> | 2023-05-15 00:05:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-14 21:05:35 +0000 |
commit | 2cd1c87d2a23ffd00730b5d1648304593530326c (patch) | |
tree | 1c58453861b90cd8fc67afd82d9bfa3414ac0289 | |
parent | fb8739f0b6291fb048a94d6312f59ba4d10a20ca (diff) | |
download | cpython-git-2cd1c87d2a23ffd00730b5d1648304593530326c.tar.gz |
gh-104456: Fix ref leak in _ctypes.COMError (#104457)
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index f6cda45eae..534ef8c1d6 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -5477,10 +5477,16 @@ comerror_init(PyObject *self, PyObject *args, PyObject *kwds) } static int +comerror_clear(PyObject *self) +{ + return ((PyTypeObject *)PyExc_BaseException)->tp_clear(self); +} + +static int comerror_traverse(PyObject *self, visitproc visit, void *arg) { Py_VISIT(Py_TYPE(self)); - return 0; + return ((PyTypeObject *)PyExc_BaseException)->tp_traverse(self, visit, arg); } static void @@ -5488,6 +5494,7 @@ comerror_dealloc(PyObject *self) { PyTypeObject *tp = Py_TYPE(self); PyObject_GC_UnTrack(self); + (void)comerror_clear(self); tp->tp_free(self); Py_DECREF(tp); } @@ -5497,6 +5504,7 @@ static PyType_Slot comerror_slots[] = { {Py_tp_init, comerror_init}, {Py_tp_traverse, comerror_traverse}, {Py_tp_dealloc, comerror_dealloc}, + {Py_tp_clear, comerror_clear}, {0, NULL}, }; |