Commit 755d4ef8 authored by Sergey Fedoseev's avatar Sergey Fedoseev Committed by T. Wouters

Correct overflow check in PyTuple_New() (GH-14838)

parent 832e8640
...@@ -120,8 +120,8 @@ tuple_alloc(Py_ssize_t size) ...@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment