mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Raise SystemError when size < 0 is passed into PyString_FromStringAndSize,
PyBytes_FromStringAndSize or PyUnicode_FromStringAndSize. [issue2587]
This commit is contained in:
parent
f108320055
commit
c00eb73a30
3 changed files with 18 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue