Commit 4a8d43bb authored by Jeremy Hylton's avatar Jeremy Hylton

(Possibly) correct use of Python memory APIs.

Fix SF bug #516768 reported by Dave Wallace.

Replace use of PyMem_DEL() with PyObject_Del() on object dealloc
functions.  The use of PyMem_DEL() is incorrect for object
deallocation, because it only ever calls the low-level free().  If a
custom allocator like pymalloc is used, it needs to be called to free
the memory.
parent d27182ea
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. DAMAGE.
$Id: Acquisition.c,v 1.56 2002/01/25 17:23:06 evan Exp $ $Id: Acquisition.c,v 1.57 2002/03/08 18:34:23 jeremy Exp $
If you have questions regarding this software, If you have questions regarding this software,
contact: contact:
...@@ -256,7 +256,7 @@ Wrapper_dealloc(Wrapper *self) ...@@ -256,7 +256,7 @@ Wrapper_dealloc(Wrapper *self)
} }
else else
{ {
PyMem_DEL(self); PyObject_DEL(self);
} }
} }
...@@ -1546,7 +1546,7 @@ initAcquisition(void) ...@@ -1546,7 +1546,7 @@ initAcquisition(void)
/* Create the module and add the functions */ /* Create the module and add the functions */
m = Py_InitModule4("Acquisition", methods, m = Py_InitModule4("Acquisition", methods,
"Provide base classes for acquiring objects\n\n" "Provide base classes for acquiring objects\n\n"
"$Id: Acquisition.c,v 1.56 2002/01/25 17:23:06 evan Exp $\n", "$Id: Acquisition.c,v 1.57 2002/03/08 18:34:23 jeremy Exp $\n",
OBJECT(NULL),PYTHON_API_VERSION); OBJECT(NULL),PYTHON_API_VERSION);
d = PyModule_GetDict(m); d = PyModule_GetDict(m);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. DAMAGE.
$Id: ExtensionClass.c,v 1.50 2002/01/25 15:34:06 gvanrossum Exp $ $Id: ExtensionClass.c,v 1.51 2002/03/08 18:34:23 jeremy Exp $
If you have questions regarding this software, If you have questions regarding this software,
contact: contact:
...@@ -54,7 +54,7 @@ static char ExtensionClass_module_documentation[] = ...@@ -54,7 +54,7 @@ static char ExtensionClass_module_documentation[] =
" - They provide access to unbound methods,\n" " - They provide access to unbound methods,\n"
" - They can be called to create instances.\n" " - They can be called to create instances.\n"
"\n" "\n"
"$Id: ExtensionClass.c,v 1.50 2002/01/25 15:34:06 gvanrossum Exp $\n" "$Id: ExtensionClass.c,v 1.51 2002/03/08 18:34:23 jeremy Exp $\n"
; ;
#include <stdio.h> #include <stdio.h>
...@@ -1610,7 +1610,7 @@ CCL_dealloc(PyExtensionClass *self) ...@@ -1610,7 +1610,7 @@ CCL_dealloc(PyExtensionClass *self)
if (((PyExtensionClass*)self->ob_type) != self) { if (((PyExtensionClass*)self->ob_type) != self) {
Py_XDECREF(self->ob_type); Py_XDECREF(self->ob_type);
} }
PyMem_DEL(self); PyObject_DEL(self);
} }
static PyObject * static PyObject *
...@@ -3074,7 +3074,7 @@ subclass_dealloc(PyObject *self) ...@@ -3074,7 +3074,7 @@ subclass_dealloc(PyObject *self)
UNLESS(base_dealloced) UNLESS(base_dealloced)
{ {
Py_DECREF(self->ob_type); Py_DECREF(self->ob_type);
PyMem_DEL(self); PyObject_DEL(self);
} }
PyErr_Restore(t,v,tb); PyErr_Restore(t,v,tb);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. DAMAGE.
$Id: ThreadLock.c,v 1.11 2002/01/25 15:34:06 gvanrossum Exp $ $Id: ThreadLock.c,v 1.12 2002/03/08 18:34:23 jeremy Exp $
If you have questions regarding this software, If you have questions regarding this software,
contact: contact:
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
*/ */
static char ThreadLock_module_documentation[] = static char ThreadLock_module_documentation[] =
"" ""
"\n$Id: ThreadLock.c,v 1.11 2002/01/25 15:34:06 gvanrossum Exp $" "\n$Id: ThreadLock.c,v 1.12 2002/03/08 18:34:23 jeremy Exp $"
; ;
#include "Python.h" #include "Python.h"
...@@ -213,7 +213,7 @@ ThreadLock_dealloc(ThreadLockObject *self) ...@@ -213,7 +213,7 @@ ThreadLock_dealloc(ThreadLockObject *self)
#ifdef WITH_THREAD #ifdef WITH_THREAD
free_lock(self->lock); free_lock(self->lock);
#endif #endif
PyMem_DEL(self); PyObject_DEL(self);
} }
static PyObject * static PyObject *
...@@ -274,7 +274,7 @@ newThreadLockObject(ThreadLockObject *self, PyObject *args) ...@@ -274,7 +274,7 @@ newThreadLockObject(ThreadLockObject *self, PyObject *args)
#ifdef WITH_THREAD #ifdef WITH_THREAD
self->lock = allocate_lock(); self->lock = allocate_lock();
if (self->lock == NULL) { if (self->lock == NULL) {
PyMem_DEL(self); PyObject_DEL(self);
self = NULL; self = NULL;
PyErr_SetString(ErrorObject, "can't allocate lock"); PyErr_SetString(ErrorObject, "can't allocate lock");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment