[Python-checkins] Correct overflow check in PyTuple_New() (GH-14838)
T. Wouters
webhook-mailer at python.org
Mon Sep 9 16:41:02 EDT 2019
https://github.com/python/cpython/commit/755d4ef8243050e5ff973524633caebd0ce03af9
commit: 755d4ef8243050e5ff973524633caebd0ce03af9
branch: master
author: Sergey Fedoseev <fedoseev.sergey at gmail.com>
committer: T. Wouters <thomas at python.org>
date: 2019-09-09T13:40:58-07:00
summary:
Correct overflow check in PyTuple_New() (GH-14838)
files:
M Objects/tupleobject.c
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index a72257f95b08..08f7022fda25 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -120,8 +120,8 @@ tuple_alloc(Py_ssize_t size)
#endif
{
/* Check for overflow */
- if ((size_t)size > ((size_t)PY_SSIZE_T_MAX - sizeof(PyTupleObject) -
- sizeof(PyObject *)) / sizeof(PyObject *)) {
+ if ((size_t)size > ((size_t)PY_SSIZE_T_MAX - (sizeof(PyTupleObject) -
+ sizeof(PyObject *))) / sizeof(PyObject *)) {
return (PyTupleObject *)PyErr_NoMemory();
}
op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size);
More information about the Python-checkins
mailing list