[Python-Dev] Re: [Patch #103248] Fix a memory leak in _sre.c
Charles G Waldman
cgw@fnal.gov
Tue, 16 Jan 2001 14:19:09 -0600 (CST)
Frederik - I noticed that you chose to check in a slightly different
patch than the one I submitted.
I wonder why you chose to do this? In particular at line 1238 I had:
if (PyErr_Occurred()) {
Py_DECREF(self);
return NULL;
}
and you changed this to
if (PyErr_Occurred()) {
PyObject_DEL(self);
return NULL;
}
Can you explain why you made this (seemingly arbitrary) change?
I think that since "self" was created via:
self = PyObject_NEW_VAR(PatternObject, &Pattern_Type, n);
which calls PyObjectINIT, which in turn calls _Py_NewReference, which
increments _Py_RefTotal, it is incorrect to simply do a PyObject_DEL
to de-allocate it -- won't this screw up the value of _Py_RefTotal?
Admittedly this is a minor nit and only matters if Py_TRACE_REFS is
defined - I just wanted to check to make sure my understanding of
reference counting w.r.t. memory allocation and deallocation is
correct - if the above is in error, I'd apprecate any corrections...