mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Issue #16096: Fix several occurrences of potential signed integer overflow. Thanks Serhiy Storchaka.
This commit is contained in:
parent
a2028733ef
commit
c04ddff290
7 changed files with 30 additions and 35 deletions
|
@ -177,12 +177,12 @@ escape_encode(PyObject *self,
|
|||
return NULL;
|
||||
|
||||
size = PyBytes_GET_SIZE(str);
|
||||
newsize = 4*size;
|
||||
if (newsize > PY_SSIZE_T_MAX || newsize / 4 != size) {
|
||||
if (size > PY_SSIZE_T_MAX / 4) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"string is too large to encode");
|
||||
return NULL;
|
||||
}
|
||||
newsize = 4*size;
|
||||
v = PyBytes_FromStringAndSize(NULL, newsize);
|
||||
|
||||
if (v == NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue