diff options
author | Stefan Krah <skrah@bytereef.org> | 2015-02-01 16:19:23 +0100 |
---|---|---|
committer | Stefan Krah <skrah@bytereef.org> | 2015-02-01 16:19:23 +0100 |
commit | efb06e2ebefacd4af258142ac5694ea04f6489b7 (patch) | |
tree | dbce51516034e91f4a72899618161f683f586efc /Objects | |
parent | 40cba286a41f2f2b79ba128beeb3f32a27a00083 (diff) | |
download | cpython-efb06e2ebefacd4af258142ac5694ea04f6489b7.tar.gz |
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 eec953205e..9ed3f922cc 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -488,7 +488,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(); @@ -510,10 +510,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); |