mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Merge issue #12973 list_repeat fix.
This commit is contained in:
commit
8f53d092f2
2 changed files with 7 additions and 3 deletions
|
@ -10,6 +10,10 @@ What's New in Python 3.3 Alpha 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #12973: Fix overflow check that relied on undefined behaviour in
|
||||||
|
list_repeat. This bug caused test_list to fail with recent versions
|
||||||
|
of Clang.
|
||||||
|
|
||||||
- Issue #12904: os.utime, os.futimes, os.lutimes, and os.futimesat now write
|
- Issue #12904: os.utime, os.futimes, os.lutimes, and os.futimesat now write
|
||||||
atime and mtime with nanosecond precision on modern POSIX platforms.
|
atime and mtime with nanosecond precision on modern POSIX platforms.
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
|
||||||
if (newsize == 0)
|
if (newsize == 0)
|
||||||
new_allocated = 0;
|
new_allocated = 0;
|
||||||
items = self->ob_item;
|
items = self->ob_item;
|
||||||
if (new_allocated <= ((~(size_t)0) / sizeof(PyObject *)))
|
if (new_allocated <= (PY_SIZE_MAX / sizeof(PyObject *)))
|
||||||
PyMem_RESIZE(items, PyObject *, new_allocated);
|
PyMem_RESIZE(items, PyObject *, new_allocated);
|
||||||
else
|
else
|
||||||
items = NULL;
|
items = NULL;
|
||||||
|
@ -510,9 +510,9 @@ list_repeat(PyListObject *a, Py_ssize_t n)
|
||||||
PyObject *elem;
|
PyObject *elem;
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
n = 0;
|
n = 0;
|
||||||
size = Py_SIZE(a) * n;
|
if (n > 0 && Py_SIZE(a) > PY_SSIZE_T_MAX / n)
|
||||||
if (n && size/n != Py_SIZE(a))
|
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
size = Py_SIZE(a) * n;
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return PyList_New(0);
|
return PyList_New(0);
|
||||||
np = (PyListObject *) PyList_New(size);
|
np = (PyListObject *) PyList_New(size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue