Skip to content

Commit d8e1c8c

Browse files
authored
Merge pull request #30153 from mdavidsaver/fix-decref-PyArray_NewFromDescr
BUG: decref on error in PyArray_NewFromDescr (#30152)
2 parents 6163117 + 05eab25 commit d8e1c8c

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎numpy/_core/src/multiarray/ctors.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -992,15 +992,16 @@ PyArray_NewFromDescr(
992992
int nd, npy_intp const *dims, npy_intp const *strides, void *data,
993993
int flags, PyObject *obj)
994994
{
995-
if (subtype == NULL) {
995+
if (descr == NULL) {
996996
PyErr_SetString(PyExc_ValueError,
997-
"subtype is NULL in PyArray_NewFromDescr");
997+
"descr is NULL in PyArray_NewFromDescr");
998998
return NULL;
999999
}
10001000

1001-
if (descr == NULL) {
1001+
if (subtype == NULL) {
10021002
PyErr_SetString(PyExc_ValueError,
1003-
"descr is NULL in PyArray_NewFromDescr");
1003+
"subtype is NULL in PyArray_NewFromDescr");
1004+
Py_DECREF(descr);
10041005
return NULL;
10051006
}
10061007

0 commit comments

Comments
 (0)