diff options
author | Stefan Krah <skrah@bytereef.org> | 2015-02-01 15:10:35 (GMT) |
---|---|---|
committer | Stefan Krah <skrah@bytereef.org> | 2015-02-01 15:10:35 (GMT) |
commit | 0a7fc53be297b718af0c02de3abbd1f94f78f9c1 (patch) | |
tree | d5b6918011aac1872d6a7ddcb564038ba486cdc8 /Objects | |
parent | caaaa1413a38f2e96511186c18ae3af02c86abaa (diff) | |
download | cpython-0a7fc53be297b718af0c02de3abbd1f94f78f9c1.zip cpython-0a7fc53be297b718af0c02de3abbd1f94f78f9c1.tar.gz cpython-0a7fc53be297b718af0c02de3abbd1f94f78f9c1.tar.bz2 |
Issue #23370: Fix off-by-one error for non-contiguous buffers.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 83a48ba..64a1a38 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -550,7 +550,7 @@ PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort) /* Otherwise a more elaborate scheme is needed */ - /* XXX(nnorwitz): need to check for overflow! */ + /* view->ndim <= 64 */ indices = (Py_ssize_t *)PyMem_Malloc(sizeof(Py_ssize_t)*(view->ndim)); if (indices == NULL) { PyErr_NoMemory(); @@ -572,10 +572,10 @@ PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort) */ elements = len / view->itemsize; while (elements--) { - addone(view->ndim, indices, view->shape); ptr = PyBuffer_GetPointer(view, indices); memcpy(ptr, src, view->itemsize); src += view->itemsize; + addone(view->ndim, indices, view->shape); } PyMem_Free(indices); |