mirror of
https://github.com/python/cpython.git
synced 2026-01-29 10:42:17 +00:00
Backport r62261 from trunk:
Prevent PyString_FromStringAndSize() from passing negative sizes on to lower level memory allocation functions. Raise a SystemError and return NULL instead.
This commit is contained in:
parent
3782da4e0a
commit
14acde30f6
2 changed files with 13 additions and 3 deletions
|
|
@ -54,6 +54,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++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue