mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
Correct overflow check in PyTuple_New() (GH-14838)
This commit is contained in:
parent
832e864008
commit
755d4ef824
1 changed files with 2 additions and 2 deletions
|
@ -120,8 +120,8 @@ tuple_alloc(Py_ssize_t size)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Check for overflow */
|
/* Check for overflow */
|
||||||
if ((size_t)size > ((size_t)PY_SSIZE_T_MAX - sizeof(PyTupleObject) -
|
if ((size_t)size > ((size_t)PY_SSIZE_T_MAX - (sizeof(PyTupleObject) -
|
||||||
sizeof(PyObject *)) / sizeof(PyObject *)) {
|
sizeof(PyObject *))) / sizeof(PyObject *)) {
|
||||||
return (PyTupleObject *)PyErr_NoMemory();
|
return (PyTupleObject *)PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size);
|
op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue