10000 Add zero PyObject pointer null-check · numpy/numpy@41cd4e1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 41cd4e1

Browse files
committed
Add zero PyObject pointer null-check
1 parent 0b60753 commit 41cd4e1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

numpy/core/src/multiarray/ctors.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,11 +3051,15 @@ static npy_intp
30513051
_calc_length(PyObject *start, PyObject *stop, PyObject *step, PyObject **next, int cmplx)
30523052
{
30533053
npy_intp len, tmp;
3054-
PyObject *zero = PyInt_FromLong(0);
3055-
PyObject *val;
3054+
PyObject *zero, *val;
30563055
int next_is_nonzero, val_is_zero;
30573056
double value;
30583057

3058+
zero = PyInt_FromLong(0);
3059+
if (!zero) {
3060+
return -1;
3061+
}
3062+
30593063
*next = PyNumber_Subtract(stop, start);
30603064
if (!(*next)) {
30613065
Py_DECREF(zero);

0 commit comments

Comments
 (0)
0