Skip to content

Commit 4bcde89

Browse files
Merge pull request #536 from neutrinoceros/bug/523
2 parents 28c491d + 13224ff commit 4bcde89

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

bottleneck/src/nonreduce_axis_template.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,13 @@ NRA(rankdata, DTYPE0) {
202202
npy_DTYPE1 old, new, averank, sumranks = 0;
203203

204204
PyObject *z = PyArray_ArgSort(a, axis, NPY_QUICKSORT);
205+
if (z == NULL) return NULL;
205206
PyObject *y = PyArray_EMPTY(PyArray_NDIM(a),
206207
PyArray_SHAPE(a), NPY_DTYPE1, 0);
208+
if (y == NULL) {
209+
Py_DECREF(z);
210+
return NULL;
211+
}
207212

208213
iter3 it;
209214
init_iter3(&it, a, y, z, axis);
@@ -264,8 +269,13 @@ NRA(nanrankdata, DTYPE0) {
264269
npy_DTYPE1 old, new, averank, sumranks = 0;
265270

266271
PyObject *z = PyArray_ArgSort(a, axis, NPY_QUICKSORT);
272+
if (z == NULL) return NULL;
267273
PyObject *y = PyArray_EMPTY(PyArray_NDIM(a),
268274
PyArray_SHAPE(a), NPY_DTYPE1, 0);
275+
if (y == NULL) {
276+
Py_DECREF(z);
277+
return NULL;
278+
}
269279

270280
iter3 it;
271281
init_iter3(&it, a, y, z, axis);

0 commit comments

Comments
 (0)