[issue3299] invalid object destruction in re.finditer()

Fredrik Lundh report at bugs.python.org
Sun Jul 6 20:32:27 CEST 2008


Fredrik Lundh <effbot at users.sourceforge.net> added the comment:

This report makes no sense to me; at least in Python 2.X, PyObject_Del
removes a chunk of memory from the object heap.  It's designed to be
used from dealloc implementations, to release the actual memory (either
directly, or as the default implementation for the tp_free slot).  It
can also be used in constructors, to destroy an object that was just
created if something goes wrong.

If you change PyObject_Del to Py_DECREF nillywilly, things will indeed
crash.

(with the original 2.5 code, I cannot see how a non-string argument to
finditer() can result in a call to scanner_dealloc(); the argument will
be rejected by getstring(), which causes state_init() to return, which
causes pattern_scanner() to free the object it just created, and return.)

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3299>
_______________________________________


More information about the Python-bugs-list mailing list