Raise SystemError when size < 0 is passed into PyString_FromStringAndSize,

PyBytes_FromStringAndSize or PyUnicode_FromStringAndSize.  [issue2587]
This commit is contained in:
Gregory P. Smith 2008-04-09 23:16:37 +00:00
parent f108320055
commit c00eb73a30
3 changed files with 18 additions and 0 deletions

View file

@ -56,6 +56,11 @@ PyString_FromStringAndSize(const char *str, Py_ssize_t size)
{
register PyStringObject *op;
assert(size >= 0);
if (size < 0) {
PyErr_SetString(PyExc_SystemError,
"Negative size passed to PyString_FromStringAndSize");
return NULL;
}
if (size == 0 && (op = nullstring) != NULL) {
#ifdef COUNT_ALLOCS
null_strings++;