mirror of
https://github.com/python/cpython.git
synced 2025-09-03 07:28:59 +00:00
gh-104456: Fix ref leak in _ctypes.COMError (#104457)
This commit is contained in:
parent
fb8739f0b6
commit
2cd1c87d2a
1 changed files with 9 additions and 1 deletions
|
@ -5476,11 +5476,17 @@ comerror_init(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
comerror_clear(PyObject *self)
|
||||||
|
{
|
||||||
|
return ((PyTypeObject *)PyExc_BaseException)->tp_clear(self);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
comerror_traverse(PyObject *self, visitproc visit, void *arg)
|
comerror_traverse(PyObject *self, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
Py_VISIT(Py_TYPE(self));
|
Py_VISIT(Py_TYPE(self));
|
||||||
return 0;
|
return ((PyTypeObject *)PyExc_BaseException)->tp_traverse(self, visit, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -5488,6 +5494,7 @@ comerror_dealloc(PyObject *self)
|
||||||
{
|
{
|
||||||
PyTypeObject *tp = Py_TYPE(self);
|
PyTypeObject *tp = Py_TYPE(self);
|
||||||
PyObject_GC_UnTrack(self);
|
PyObject_GC_UnTrack(self);
|
||||||
|
(void)comerror_clear(self);
|
||||||
tp->tp_free(self);
|
tp->tp_free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
@ -5497,6 +5504,7 @@ static PyType_Slot comerror_slots[] = {
|
||||||
{Py_tp_init, comerror_init},
|
{Py_tp_init, comerror_init},
|
||||||
{Py_tp_traverse, comerror_traverse},
|
{Py_tp_traverse, comerror_traverse},
|
||||||
{Py_tp_dealloc, comerror_dealloc},
|
{Py_tp_dealloc, comerror_dealloc},
|
||||||
|
{Py_tp_clear, comerror_clear},
|
||||||
{0, NULL},
|
{0, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue