summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-06-05 09:38:18 -0700
committerEric Wieser <wieser.eric@gmail.com>2018-06-05 09:38:18 -0700
commit644c78809ff5b53b0fcdbb35e5823fc6e01d24ac (patch)
tree1c08f7c08c259dc1cc218ec7ab0662229fb64cd0
parent4c019647e7ddc22da8fa20468785381526ba450a (diff)
downloadnumpy-644c78809ff5b53b0fcdbb35e5823fc6e01d24ac.tar.gz
BUG: Prevent memory leak if PyArray_NewCopy fails
-rw-r--r--numpy/core/src/multiarray/shape.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/shape.c b/numpy/core/src/multiarray/shape.c
index c8198be56..adc77dfce 100644
--- a/numpy/core/src/multiarray/shape.c
+++ b/numpy/core/src/multiarray/shape.c
@@ -244,10 +244,10 @@ PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims,
else {
PyObject *newcopy;
newcopy = PyArray_NewCopy(self, order);
+ Py_DECREF(self);
if (newcopy == NULL) {
return NULL;
}
- Py_DECREF(self);
self = (PyArrayObject *)newcopy;
}
}