mirror of https://github.com/python/cpython
GH-92804: Fix memory leak in memoryview iterator (gh-92805)
This commit is contained in:
parent
2e8f721c0f
commit
d923fdf54b
|
@ -0,0 +1 @@
|
||||||
|
Fix memory leak in ``memoryview`` iterator as it was not finalized at exit. Patch by Kumar Aditya.
|
|
@ -3156,7 +3156,7 @@ static PyMethodDef memory_methods[] = {
|
||||||
/* Memoryview Iterator */
|
/* Memoryview Iterator */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
static PyTypeObject PyMemoryIter_Type;
|
PyTypeObject _PyMemoryIter_Type;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
|
@ -3233,7 +3233,7 @@ memory_iter(PyObject *seq)
|
||||||
}
|
}
|
||||||
|
|
||||||
memoryiterobject *it;
|
memoryiterobject *it;
|
||||||
it = PyObject_GC_New(memoryiterobject, &PyMemoryIter_Type);
|
it = PyObject_GC_New(memoryiterobject, &_PyMemoryIter_Type);
|
||||||
if (it == NULL) {
|
if (it == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -3246,7 +3246,7 @@ memory_iter(PyObject *seq)
|
||||||
return (PyObject *)it;
|
return (PyObject *)it;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyTypeObject PyMemoryIter_Type = {
|
PyTypeObject _PyMemoryIter_Type = {
|
||||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||||
.tp_name = "memory_iterator",
|
.tp_name = "memory_iterator",
|
||||||
.tp_basicsize = sizeof(memoryiterobject),
|
.tp_basicsize = sizeof(memoryiterobject),
|
||||||
|
|
|
@ -1845,6 +1845,7 @@ _PyTypes_InitState(PyInterpreterState *interp)
|
||||||
extern PyTypeObject PyHKEY_Type;
|
extern PyTypeObject PyHKEY_Type;
|
||||||
#endif
|
#endif
|
||||||
extern PyTypeObject _Py_GenericAliasIterType;
|
extern PyTypeObject _Py_GenericAliasIterType;
|
||||||
|
extern PyTypeObject _PyMemoryIter_Type;
|
||||||
|
|
||||||
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,6 +1945,7 @@ static PyTypeObject* static_types[] = {
|
||||||
&_PyHamt_Type,
|
&_PyHamt_Type,
|
||||||
&_PyInterpreterID_Type,
|
&_PyInterpreterID_Type,
|
||||||
&_PyManagedBuffer_Type,
|
&_PyManagedBuffer_Type,
|
||||||
|
&_PyMemoryIter_Type,
|
||||||
&_PyMethodWrapper_Type,
|
&_PyMethodWrapper_Type,
|
||||||
&_PyNamespace_Type,
|
&_PyNamespace_Type,
|
||||||
&_PyNone_Type,
|
&_PyNone_Type,
|
||||||
|
|
Loading…
Reference in New Issue