summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-04-26 00:53:34 (GMT)
committerGuido van Rossum <guido@python.org>2002-04-26 00:53:34 (GMT)
commit93646981011b0795329888bf7d2d10097e899432 (patch)
tree869df4116ed907ed35df45bc8bf399fd7ba55588 /Objects
parentcf22c826a68ccf33fa3f093f7dc9da956d69127e (diff)
downloadcpython-93646981011b0795329888bf7d2d10097e899432.zip
cpython-93646981011b0795329888bf7d2d10097e899432.tar.gz
cpython-93646981011b0795329888bf7d2d10097e899432.tar.bz2
Make sure that tp_free frees the int the same way as tp_dealloc would.
This fixes the problem that Barry reported on python-dev: >>> 23000 .__class__ = bool crashes in the deallocator. This was because int inherited tp_free from object, which uses the default allocator. 2.2. Bugfix candidate.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/intobject.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 5886209..58a6beb 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -130,6 +130,13 @@ int_dealloc(PyIntObject *v)
v->ob_type->tp_free((PyObject *)v);
}
+static void
+int_free(PyIntObject *v)
+{
+ v->ob_type = (struct _typeobject *)free_list;
+ free_list = v;
+}
+
long
PyInt_AsLong(register PyObject *op)
{
@@ -905,6 +912,7 @@ PyTypeObject PyInt_Type = {
0, /* tp_init */
0, /* tp_alloc */
int_new, /* tp_new */
+ (freefunc)int_free, /* tp_free */
};
void