diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2019-08-08 14:33:03 -0500 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2019-08-19 13:13:36 -0500 |
commit | c091779f63521e13d9f7af4ff113dde8cc5f6a7f (patch) | |
tree | ce1e29da778995b4467064d278a6a58a946e11ee /numpy/f2py/tests/src/array_from_pyobj | |
parent | 684bee2ae868c1bd8cb4fd4066d447ca35bd848e (diff) | |
download | numpy-c091779f63521e13d9f7af4ff113dde8cc5f6a7f.tar.gz |
BUG: Further, followup f2py reference count fixes
Note that the extension module dict seems to be never dereferenced
(there is an additional reference to it kept around somewhere).
This reference seems to part of the C python module loading
(possibly intentionally), and I could not find how to remove it or
where it originates from.
Diffstat (limited to 'numpy/f2py/tests/src/array_from_pyobj')
-rw-r--r-- | numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c index fbc2090e1..978db4e69 100644 --- a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c +++ b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c @@ -49,9 +49,18 @@ static PyObject *f2py_rout_wrap_call(PyObject *capi_self, return NULL; rank = PySequence_Length(dims_capi); dims = malloc(rank*sizeof(npy_intp)); - for (i=0;i<rank;++i) - dims[i] = (npy_intp)PyInt_AsLong(PySequence_GetItem(dims_capi,i)); - + for (i=0;i<rank;++i) { + PyObject *tmp; + tmp = PySequence_GetItem(dims_capi, i); + if (tmp == NULL) { + goto fail; + } + dims[i] = (npy_intp)PyInt_AsLong(tmp); + Py_DECREF(tmp); + if (dims[i] == -1 && PyErr_Occurred()) { + goto fail; + } + } capi_arr_tmp = array_from_pyobj(type_num,dims,rank,intent|F2PY_INTENT_OUT,arr_capi); if (capi_arr_tmp == NULL) { free(dims); @@ -60,6 +69,10 @@ static PyObject *f2py_rout_wrap_call(PyObject *capi_self, capi_buildvalue = Py_BuildValue("N",capi_arr_tmp); free(dims); return capi_buildvalue; + +fail: + free(dims); + return NULL; } static char doc_f2py_rout_wrap_attrs[] = "\ |