summaryrefslogtreecommitdiff
path: root/numpy/core/src/multiarray
diff options
context:
space:
mode:
authorAlexandre de Siqueira <alex.desiqueira@igdore.org>2022-02-16 08:46:02 -0800
committerGitHub <noreply@github.com>2022-02-16 10:46:02 -0600
commit935fe83ddaa3250d176bc848579ffdc4e1017090 (patch)
tree75a5b0ec027cfcd6633e4cf6d9de801357a8d96a /numpy/core/src/multiarray
parentf80aba83de3027a08597b13107e549f401a2ec40 (diff)
downloadnumpy-935fe83ddaa3250d176bc848579ffdc4e1017090.tar.gz
BUG: Fix unpickling an empty ndarray with a none-zero dimension (#21067)
Changing num to the number of bytes in the input array, PyArray_NBYTES(self). Solves #21009. * Fixing nbyte size in methods.c:memcpy * Adding a test * Re-adding removed newline * Shrinking the test array to save memory
Diffstat (limited to 'numpy/core/src/multiarray')
-rw-r--r--numpy/core/src/multiarray/methods.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c
index 792686cf0..bd6318206 100644
--- a/numpy/core/src/multiarray/methods.c
+++ b/numpy/core/src/multiarray/methods.c
@@ -2205,7 +2205,7 @@ array_setstate(PyArrayObject *self, PyObject *args)
Py_DECREF(typecode);
}
else {
- memcpy(PyArray_DATA(self), datastr, num);
+ memcpy(PyArray_DATA(self), datastr, PyArray_NBYTES(self));
}
PyArray_ENABLEFLAGS(self, NPY_ARRAY_OWNDATA);
fa->base = NULL;