diff options
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r-- | Objects/bytesobject.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 23de37e..af7a1b1 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -161,6 +161,11 @@ PyBytes_FromStringAndSize(const char *bytes, Py_ssize_t size) Py_ssize_t alloc; assert(size >= 0); + if (size < 0) { + PyErr_SetString(PyExc_SystemError, + "Negative size passed to PyBytes_FromStringAndSize"); + return NULL; + } new = PyObject_New(PyBytesObject, &PyBytes_Type); if (new == NULL) |