Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a1e9ec4

Browse files
committed
Correct a memory leak: the range() object was not properly freed.
1 parent a041ba5 commit a1e9ec4

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

Objects/object.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,9 @@ _Py_ReadyTypes(void)
15091509

15101510
if (PyType_Ready(&PyStdPrinter_Type) < 0)
15111511
Py_FatalError("Can't initialize StdPrinter");
1512+
1513+
if (PyType_Ready(&PyRange_Type) < 0)
1514+
Py_FatalError("Can't initialize 'range'");
15121515
}
15131516

15141517

Objects/rangeobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ range_dealloc(rangeobject *r)
107107
Py_DECREF(r->start);
108108
Py_DECREF(r->stop);
109109
Py_DECREF(r->step);
110+
Py_Type(r)->tp_free(r);
110111
}
111112

112113
/* Return number of items in range (lo, hi, step), when arguments are

0 commit comments

Comments
 (0)