Skip to content

Commit 09326eb

Browse files
committed
Fixups based on review comments.
1 parent c2de2d1 commit 09326eb

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

numpy/core/src/multiarray/array_coercion.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ npy_new_coercion_cache(
555555
cache = PyMem_Malloc(sizeof(coercion_cache_obj));
556556
}
557557
if (cache == NULL) {
558+
Py_DECREF(arr_or_sequence);
558559
PyErr_NoMemory();
559560
return -1;
560561
}
@@ -1089,7 +1090,6 @@ PyArray_DiscoverDTypeAndShape_Recursive(
10891090
}
10901091
/* The cache takes ownership of the sequence here. */
10911092
if (npy_new_coercion_cache(obj, seq, 1, coercion_cache_tail_ptr, curr_dims) < 0) {
1092-
Py_DECREF(seq);
10931093
return -1;
10941094
}
10951095

numpy/core/src/multiarray/multiarraymodule.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4669,14 +4669,14 @@ PyMODINIT_FUNC PyInit__multiarray_umath(void) {
46694669
PyObject *m, *d, *s;
46704670
PyObject *c_api;
46714671

4672-
/* Initialize CPU features */
4673-
if (npy_cpu_init() < 0) {
4674-
goto err;
4675-
}
4676-
46774672
/* Create the module and add the functions */
46784673
m = PyModule_Create(&moduledef);
46794674
if (!m) {
4675+
return NULL;
4676+
}
4677+
4678+
/* Initialize CPU features */
4679+
if (npy_cpu_init() < 0) {
46804680
goto err;
46814681
}
46824682

@@ -4914,6 +4914,6 @@ PyMODINIT_FUNC PyInit__multiarray_umath(void) {
49144914
PyErr_SetString(PyExc_RuntimeError,
49154915
"cannot load multiarray module.");
49164916
}
4917-
Py_XDECREF(m);
4917+
Py_DECREF(m);
49184918
return NULL;
49194919
}

numpy/core/src/multiarray/scalarapi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,12 @@ PyArray_CastScalarToCtype(PyObject *scalar, void *ctypeptr,
233233
PyArray_VectorUnaryFunc* castfunc;
234234

235235
descr = PyArray_DescrFromScalar(scalar);
236+
if (descr == NULL) {
237+
return -1;
238+
}
236239
castfunc = PyArray_GetCastFunc(descr, outcode->type_num);
237240
if (castfunc == NULL) {
238-
Py_XDECREF(descr);
241+
Py_DECREF(descr);
239242
return -1;
240243
}
241244
if (PyTypeNum_ISEXTENDED(descr->type_num) ||

0 commit comments

Comments
 (0)