summaryrefslogtreecommitdiff
path: root/numpy/f2py/src/fortranobject.c
diff options
context:
space:
mode:
authorSergei Lebedev <slebedev@google.com>2019-08-07 11:07:15 +0100
committerSebastian Berg <sebastian@sipsolutions.net>2019-08-19 11:03:59 -0500
commit4ada0641ed1a50a2473f8061f4808b4b0d68eff5 (patch)
tree1a09d526baa152b6766b0252cbf2d7e5d1cdda00 /numpy/f2py/src/fortranobject.c
parente2b5f60e6881a57f53bb6051b4555917d1e05fa7 (diff)
downloadnumpy-4ada0641ed1a50a2473f8061f4808b4b0d68eff5.tar.gz
BUG: Fix leak in the f2py-generated module init and `PyMem_Del` usage
Using `PyMem_Del` is incorrect, it should be `PyObject_Del` here, while this worked most of the time, it would lead to crashes at least on python 2.5 (after the reference counts were fixed)
Diffstat (limited to 'numpy/f2py/src/fortranobject.c')
-rw-r--r--numpy/f2py/src/fortranobject.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c
index 4a981bf55..b55385b50 100644
--- a/numpy/f2py/src/fortranobject.c
+++ b/numpy/f2py/src/fortranobject.c
@@ -80,7 +80,10 @@ PyFortranObject_NewAsAttr(FortranDataDef* defs) { /* used for calling F90 module
PyFortranObject *fp = NULL;
fp = PyObject_New(PyFortranObject, &PyFortran_Type);
if (fp == NULL) return NULL;
- if ((fp->dict = PyDict_New())==NULL) return NULL;
+ if ((fp->dict = PyDict_New())==NULL) {
+ PyObject_Del(fp);
+ return NULL;
+ }
fp->len = 1;
fp->defs = defs;
return (PyObject *)fp;
@@ -91,7 +94,7 @@ PyFortranObject_NewAsAttr(FortranDataDef* defs) { /* used for calling F90 module
static void
fortran_dealloc(PyFortranObject *fp) {
Py_XDECREF(fp->dict);
- PyMem_Del(fp);
+ PyObject_Del(fp);
}