diff options
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r-- | Objects/bytearrayobject.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index da11249..201d294 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -121,6 +121,11 @@ PyByteArray_FromStringAndSize(const char *bytes, Py_ssize_t size) return NULL; } + /* Prevent buffer overflow when setting alloc to size+1. */ + if (size == PY_SSIZE_T_MAX) { + return PyErr_NoMemory(); + } + new = PyObject_New(PyByteArrayObject, &PyByteArray_Type); if (new == NULL) return NULL; |