mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Check whether the strlen() result overflows Py_ssize_t.
This commit is contained in:
parent
9bc47120d3
commit
a14c4bbbaa
1 changed files with 5 additions and 1 deletions
|
@ -396,7 +396,11 @@ PyObject *PyUnicode_FromUnicode(const Py_UNICODE *u,
|
|||
PyObject *PyUnicode_FromString(const char *u)
|
||||
{
|
||||
PyUnicodeObject *unicode;
|
||||
Py_ssize_t size = strlen(u);
|
||||
size_t size = strlen(u);
|
||||
if (size > PY_SSIZE_T_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError, "input too long");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* If the Unicode data is known at construction time, we can apply
|
||||
some optimizations which share commonly used objects. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue