summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-09-06 05:56:32 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-09-06 05:56:32 +0000
commit61c3159dca9b35eb3e0ad6b7724900112c609123 (patch)
tree43b256a1572877199bedcc52e5af3d4ab8acc9f5
parent1072ff32e979e134737a4f9374f92af36644e8ce (diff)
downloadnumpy-61c3159dca9b35eb3e0ad6b7724900112c609123.tar.gz
Fix memory leak in corner case of lexsort.
-rw-r--r--numpy/core/src/multiarraymodule.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c
index 7847ad6e4..14daa8014 100644
--- a/numpy/core/src/multiarraymodule.c
+++ b/numpy/core/src/multiarraymodule.c
@@ -2414,9 +2414,10 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
mps[0]->dimensions,
PyArray_INTP,
NULL, NULL, 0, 0, NULL);
- if (ret == NULL) return NULL;
+
+ if (ret == NULL) goto fail;
*((intp *)(ret->data)) = 0;
- return (PyObject *)ret;
+ goto finish;
}
if (axis < 0) axis += nd;
if ((axis < 0) || (axis >= nd)) {
@@ -2502,8 +2503,9 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
NPY_END_THREADS
+ finish:
for (i=0; i<n; i++) {Py_XDECREF(mps[i]); Py_XDECREF(its[i]);}
- Py_DECREF(rit);
+ Py_XDECREF(rit);
_pya_free(mps);
_pya_free(its);
return (PyObject *)ret;