mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Add checks for size overflow on list*n, list+list, tuple+tuple.
Will backport.
This commit is contained in:
parent
6e08c1460c
commit
a5c0e6d6c8
2 changed files with 6 additions and 0 deletions
|
@ -391,6 +391,8 @@ list_concat(PyListObject *a, PyObject *bb)
|
|||
}
|
||||
#define b ((PyListObject *)bb)
|
||||
size = a->ob_size + b->ob_size;
|
||||
if (size < 0)
|
||||
return PyErr_NoMemory();
|
||||
np = (PyListObject *) PyList_New(size);
|
||||
if (np == NULL) {
|
||||
return NULL;
|
||||
|
@ -419,6 +421,8 @@ list_repeat(PyListObject *a, int n)
|
|||
if (n < 0)
|
||||
n = 0;
|
||||
size = a->ob_size * n;
|
||||
if (size/a->ob_size != n)
|
||||
return PyErr_NoMemory();
|
||||
np = (PyListObject *) PyList_New(size);
|
||||
if (np == NULL)
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue