summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2019-06-30 05:58:36 -0700
committerGitHub <noreply@github.com>2019-06-30 05:58:36 -0700
commit8d18405446cb1c7dc6db15be812a9b3fc531ede0 (patch)
treefe2d7fa6a85946ba1c6270ad2d25038b4f6941ab
parent0b7674290ea740ba01fecd849f1273408f09425f (diff)
parent45ca9d9fc7ab57b2757a37b20fdce687074f0c53 (diff)
downloadnumpy-8d18405446cb1c7dc6db15be812a9b3fc531ede0.tar.gz
Merge pull request #13870 from seberg/no-empty-alloc
MAINT,BUG: Use nbytes to also catch empty descr during allocation
-rw-r--r--numpy/core/src/multiarray/ctors.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c
index 9d01132da..6be3170eb 100644
--- a/numpy/core/src/multiarray/ctors.c
+++ b/numpy/core/src/multiarray/ctors.c
@@ -951,7 +951,7 @@ PyArray_NewFromDescr_int(
int allow_emptystring)
{
PyArrayObject_fields *fa;
- int i, is_empty;
+ int i;
npy_intp nbytes;
if (descr->subarray) {
@@ -1005,7 +1005,6 @@ PyArray_NewFromDescr_int(
}
/* Check dimensions and multiply them to nbytes */
- is_empty = 0;
for (i = 0; i < nd; i++) {
npy_intp dim = dims[i];
@@ -1014,7 +1013,6 @@ PyArray_NewFromDescr_int(
* Compare to PyArray_OverflowMultiplyList that
* returns 0 in this case.
*/
- is_empty = 1;
continue;
}
@@ -1101,8 +1099,8 @@ PyArray_NewFromDescr_int(
* (a.data) doesn't work as it should.
* Could probably just allocate a few bytes here. -- Chuck
*/
- if (is_empty) {
- nbytes = descr->elsize;
+ if (nbytes == 0) {
+ nbytes = descr->elsize ? descr->elsize : 1;
}
/*
* It is bad to have uninitialized OBJECT pointers