8000 BUG: Fixed partition errors on empty input. Closes #6530 · charris/numpy@120da4f · GitHub
[go: up one dir, main page]

Skip to content

Commit 120da4f

Browse files
yashmehrotracharris
authored andcommitted
BUG: Fixed partition errors on empty input. Closes numpy#6530
1 parent e0ca6c3 commit 120da4f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

numpy/core/src/multiarray/item_selection.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ _new_sortlike(PyArrayObject *op, int axis, PyArray_SortFunc *sort,
809809
PyArrayIterObject *it;
810810
npy_intp size;
811811

812-
int ret = -1;
812+
int ret = 0;
813813

814814
NPY_BEGIN_THREADS_DEF;
815815

@@ -829,6 +829,7 @@ _new_sortlike(PyArrayObject *op, int axis, PyArray_SortFunc *sort,
829829
if (needcopy) {
830830
buffer = PyDataMem_NEW(N * elsize);
831831
if (buffer == NULL) {
832+
ret = -1;
832833
goto fail;
833834
}
834835
}
@@ -947,7 +948,7 @@ _new_argsortlike(PyArrayObject *op, int axis, PyArray_ArgSortFunc *argsort,
947948
PyArrayIterObject *it, *rit;
948949
npy_intp size;
949950

950-
int ret = -1;
951+
int ret = 0;
951952

952953
NPY_BEGIN_THREADS_DEF;
953954

@@ -969,6 +970,7 @@ _new_argsortlike(PyArrayObject *op, int axis, PyArray_ArgSortFunc *argsort,
969970
it = (PyArrayIterObject *)PyArray_IterAllButAxis((PyObject *)op, &axis);
970971
rit = (PyArrayIterObject *)PyArray_IterAllButAxis((PyObject *)rop, &axis);
971972
if (it == NULL || rit == NULL) {
973+
ret = -1;
972974
goto fail;
973975
}
974976
size = it->size;
@@ -978,13 +980,15 @@ _new_argsortlike(PyArrayObject *op, int axis, PyArray_ArgSortFunc *argsort,
978980
if (needcopy) {
979981
valbuffer = PyDataMem_NEW(N * elsize);
980982
if (valbuffer == NULL) {
983+
ret = -1;
981984
goto fail;
982985
}
983986
}
984987

985988
if (needidxbuffer) {
986989
idxbuffer = (npy_intp *)PyDataMem_NEW(N * sizeof(npy_intp));
987990
if (idxbuffer == NULL) {
991+
ret = -1;
988992
goto fail;
989993
}
990994
}

0 commit comments

Comments
 (0)
0