mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
merge 3.4 (#23361)
This commit is contained in:
commit
5ef01e9b93
2 changed files with 14 additions and 2 deletions
|
|
@ -670,13 +670,23 @@ getenvironment(PyObject* environment)
|
|||
"environment can only contain strings");
|
||||
goto error;
|
||||
}
|
||||
if (totalsize > PY_SSIZE_T_MAX - PyUnicode_GET_LENGTH(key) - 1) {
|
||||
PyErr_SetString(PyExc_OverflowError, "environment too long");
|
||||
goto error;
|
||||
}
|
||||
totalsize += PyUnicode_GET_LENGTH(key) + 1; /* +1 for '=' */
|
||||
if (totalsize > PY_SSIZE_T_MAX - PyUnicode_GET_LENGTH(value) - 1) {
|
||||
PyErr_SetString(PyExc_OverflowError, "environment too long");
|
||||
goto error;
|
||||
}
|
||||
totalsize += PyUnicode_GET_LENGTH(value) + 1; /* +1 for '\0' */
|
||||
}
|
||||
|
||||
buffer = PyMem_Malloc(totalsize * sizeof(Py_UCS4));
|
||||
if (! buffer)
|
||||
buffer = PyMem_NEW(Py_UCS4, totalsize);
|
||||
if (! buffer) {
|
||||
PyErr_NoMemory();
|
||||
goto error;
|
||||
}
|
||||
p = buffer;
|
||||
end = buffer + totalsize;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue