mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
GH-92955: fix memory leak in code object lines and positions iterators (gh-92956)
This commit is contained in:
parent
137fd3d88a
commit
c5f5f978ca
3 changed files with 9 additions and 4 deletions
|
@ -0,0 +1 @@
|
||||||
|
Fix memory leak in code object's lines and positions iterators as they were not finalized at exit. Patch by Kumar Aditya.
|
|
@ -1096,7 +1096,7 @@ error:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyTypeObject LineIterator = {
|
PyTypeObject _PyLineIterator = {
|
||||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||||
"line_iterator", /* tp_name */
|
"line_iterator", /* tp_name */
|
||||||
sizeof(lineiterator), /* tp_basicsize */
|
sizeof(lineiterator), /* tp_basicsize */
|
||||||
|
@ -1142,7 +1142,7 @@ static PyTypeObject LineIterator = {
|
||||||
static lineiterator *
|
static lineiterator *
|
||||||
new_linesiterator(PyCodeObject *code)
|
new_linesiterator(PyCodeObject *code)
|
||||||
{
|
{
|
||||||
lineiterator *li = (lineiterator *)PyType_GenericAlloc(&LineIterator, 0);
|
lineiterator *li = (lineiterator *)PyType_GenericAlloc(&_PyLineIterator, 0);
|
||||||
if (li == NULL) {
|
if (li == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1196,7 +1196,7 @@ positionsiter_next(positionsiterator* pi)
|
||||||
_source_offset_converter, &pi->pi_endcolumn);
|
_source_offset_converter, &pi->pi_endcolumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyTypeObject PositionsIterator = {
|
PyTypeObject _PyPositionsIterator = {
|
||||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||||
"positions_iterator", /* tp_name */
|
"positions_iterator", /* tp_name */
|
||||||
sizeof(positionsiterator), /* tp_basicsize */
|
sizeof(positionsiterator), /* tp_basicsize */
|
||||||
|
@ -1242,7 +1242,7 @@ static PyTypeObject PositionsIterator = {
|
||||||
static PyObject*
|
static PyObject*
|
||||||
code_positionsiterator(PyCodeObject* code, PyObject* Py_UNUSED(args))
|
code_positionsiterator(PyCodeObject* code, PyObject* Py_UNUSED(args))
|
||||||
{
|
{
|
||||||
positionsiterator* pi = (positionsiterator*)PyType_GenericAlloc(&PositionsIterator, 0);
|
positionsiterator* pi = (positionsiterator*)PyType_GenericAlloc(&_PyPositionsIterator, 0);
|
||||||
if (pi == NULL) {
|
if (pi == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1846,6 +1846,8 @@ extern PyTypeObject PyHKEY_Type;
|
||||||
#endif
|
#endif
|
||||||
extern PyTypeObject _Py_GenericAliasIterType;
|
extern PyTypeObject _Py_GenericAliasIterType;
|
||||||
extern PyTypeObject _PyMemoryIter_Type;
|
extern PyTypeObject _PyMemoryIter_Type;
|
||||||
|
extern PyTypeObject _PyLineIterator;
|
||||||
|
extern PyTypeObject _PyPositionsIterator;
|
||||||
|
|
||||||
static PyTypeObject* static_types[] = {
|
static PyTypeObject* static_types[] = {
|
||||||
// The two most important base types: must be initialized first and
|
// The two most important base types: must be initialized first and
|
||||||
|
@ -1944,12 +1946,14 @@ static PyTypeObject* static_types[] = {
|
||||||
&_PyHamt_CollisionNode_Type,
|
&_PyHamt_CollisionNode_Type,
|
||||||
&_PyHamt_Type,
|
&_PyHamt_Type,
|
||||||
&_PyInterpreterID_Type,
|
&_PyInterpreterID_Type,
|
||||||
|
&_PyLineIterator,
|
||||||
&_PyManagedBuffer_Type,
|
&_PyManagedBuffer_Type,
|
||||||
&_PyMemoryIter_Type,
|
&_PyMemoryIter_Type,
|
||||||
&_PyMethodWrapper_Type,
|
&_PyMethodWrapper_Type,
|
||||||
&_PyNamespace_Type,
|
&_PyNamespace_Type,
|
||||||
&_PyNone_Type,
|
&_PyNone_Type,
|
||||||
&_PyNotImplemented_Type,
|
&_PyNotImplemented_Type,
|
||||||
|
&_PyPositionsIterator,
|
||||||
&_PyUnicodeASCIIIter_Type,
|
&_PyUnicodeASCIIIter_Type,
|
||||||
&_PyUnion_Type,
|
&_PyUnion_Type,
|
||||||
&_PyWeakref_CallableProxyType,
|
&_PyWeakref_CallableProxyType,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue