diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-08-30 19:40:20 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-08-30 19:40:20 (GMT) |
commit | 326e189410106de22c4af9d8449e0a8dc631c7dc (patch) | |
tree | aee14795e7baf029f61b898631d32af264782be3 /Modules | |
parent | caa745e7ca238313293de8cfe183df3d92f18cc9 (diff) | |
download | cpython-326e189410106de22c4af9d8449e0a8dc631c7dc.zip cpython-326e189410106de22c4af9d8449e0a8dc631c7dc.tar.gz cpython-326e189410106de22c4af9d8449e0a8dc631c7dc.tar.bz2 |
Issue #9651: Fix a crash when ctypes.create_string_buffer(0) was passed to
some functions like file.write().
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 8e85980..277206c 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2488,8 +2488,10 @@ static int PyCData_NewGetBuffer(PyObject *_self, Py_buffer *view, int flags) view->ndim = dict->ndim; view->shape = dict->shape; view->itemsize = self->b_size; - for (i = 0; i < view->ndim; ++i) { - view->itemsize /= dict->shape[i]; + if (view->itemsize) { + for (i = 0; i < view->ndim; ++i) { + view->itemsize /= dict->shape[i]; + } } view->strides = NULL; view->suboffsets = NULL; |