Mercurial > cpython-lru_cache-weakref
diff Modules/arraymodule.c @ 42669:2c51be9904de
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.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Sun, 19 Aug 2007 04:23:20 +0000 |
| parents | 85c22b4d4455 |
| children | cd4591b754e0 |
line wrap: on
line diff
--- a/Modules/arraymodule.c Sat Aug 18 22:05:58 2007 +0000 +++ b/Modules/arraymodule.c Sun Aug 19 04:23:20 2007 +0000 @@ -42,10 +42,8 @@ #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 @@ 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';
