diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-19 04:23:20 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-19 04:23:20 (GMT) |
commit | faa54a392951468090f0095ffa927b16fcb20ca4 (patch) | |
tree | a8586a5cc833217e6b1eaf4d052313475534178a /Modules | |
parent | 1836358c016cd7f5117f4f34fa3a27c5701e8265 (diff) | |
download | cpython-faa54a392951468090f0095ffa927b16fcb20ca4.zip cpython-faa54a392951468090f0095ffa927b16fcb20ca4.tar.gz cpython-faa54a392951468090f0095ffa927b16fcb20ca4.tar.bz2 |
Code review of the new buffer protocol. Mostly add questions that should
be answered with the comments removed.
There are many places that require checks when doing arithmetic for memory
sizes when allocating memory. Otherwise, overflow is possible with
a subsequent crash.
Fix SF #1777057 which was a result of not initializing the new BufferError
properly. Had to update the test for exceptions for BufferError too.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/arraymodule.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 656fc09..0e8673f 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -42,10 +42,8 @@ static PyTypeObject Arraytype; #ifdef Py_UNICODE_WIDE #define PyArr_UNI 'w' -/*static const char *PyArr_UNISTR = "w"; */ #else #define PyArr_UNI 'u' -/*static const char *PyArr_UNISTR = "u"; */ #endif #define array_Check(op) PyObject_TypeCheck(op, &Arraytype) @@ -1773,6 +1771,8 @@ array_buffer_getbuf(arrayobject *self, PyBuffer *view, int flags) view->internal = NULL; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->internal = malloc(3); + /* XXX(nnorwitz): need to check for malloc failure. + Should probably use PyObject_Malloc. */ view->format = view->internal; view->format[0] = (char)(self->ob_descr->typecode); view->format[1] = '\0'; |