Skip to content

Commit

Permalink
Merge pull request #25425 from seberg/mem-errors
Browse files Browse the repository at this point in the history
BUG: Fix two errors related to not checking for failed allocations
  • Loading branch information
charris committed Dec 19, 2023
2 parents 81ac1c4 + 40c5a41 commit b9a0c9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions numpy/_core/src/multiarray/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,11 +935,11 @@ array_boolean_subscript(PyArrayObject *self,
Py_INCREF(dtype);
ret = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, dtype, 1, &size,
NULL, NULL, 0, NULL);
/* not same as *dtype* if the DType class replaces dtypes */
ret_dtype = PyArray_DESCR(ret);
if (ret == NULL) {
return NULL;
}
/* not same as *dtype* if the DType class replaces dtypes */
ret_dtype = PyArray_DESCR(ret);

itemsize = dtype->elsize;
ret_data = PyArray_DATA(ret);
Expand Down
3 changes: 3 additions & 0 deletions numpy/_core/src/multiarray/nditer_constr.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ NpyIter_AdvancedNew(int nop, PyArrayObject **op_in, npy_uint32 flags,
/* Allocate memory for the iterator */
iter = (NpyIter*)
PyObject_Malloc(NIT_SIZEOF_ITERATOR(itflags, ndim, nop));
if (iter == NULL) {
return NULL;
}

NPY_IT_TIME_POINT(c_malloc);

Expand Down

0 comments on commit b9a0c9e

Please sign in to comment.