diff options
author | Stefan Krah <skrah@bytereef.org> | 2015-01-30 19:11:10 (GMT) |
---|---|---|
committer | Stefan Krah <skrah@bytereef.org> | 2015-01-30 19:11:10 (GMT) |
commit | 5606cd980023f07d5cc8f063727990108f0875c4 (patch) | |
tree | 1e3fe4fd0ef3abcf5722d57a467f569f9763b0d0 /Objects | |
parent | 61ec71d7bd2235f927e39fbf953f5056b962a101 (diff) | |
download | cpython-5606cd980023f07d5cc8f063727990108f0875c4.zip cpython-5606cd980023f07d5cc8f063727990108f0875c4.tar.gz cpython-5606cd980023f07d5cc8f063727990108f0875c4.tar.bz2 |
Issue #23349: Fix off-by-one error in PyBuffer_ToContiguous(). Initial patch
by Richard Hansen.
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 5707eb2..83a48ba 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -499,7 +499,7 @@ PyBuffer_ToContiguous(void *buf, Py_buffer *view, 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(); @@ -521,10 +521,10 @@ PyBuffer_ToContiguous(void *buf, Py_buffer *view, Py_ssize_t len, char fort) */ elements = len / view->itemsize; while (elements--) { - addone(view->ndim, indices, view->shape); ptr = PyBuffer_GetPointer(view, indices); memcpy(dest, ptr, view->itemsize); dest += view->itemsize; + addone(view->ndim, indices, view->shape); } PyMem_Free(indices); return 0; |