File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ What's New in Python 3.2.3?
10
10
Core and Builtins
11
11
-----------------
12
12
13
+ - Issue #12973: Fix overflow check that relied on undefined behaviour in
14
+ list_repeat. This bug caused test_list to fail with recent versions
15
+ of Clang.
16
+
13
17
- Issue #12802: the Windows error ERROR_DIRECTORY (numbered 267) is now
14
18
mapped to POSIX errno ENOTDIR (previously EINVAL).
15
19
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
58
58
if (newsize == 0 )
59
59
new_allocated = 0 ;
60
60
items = self -> ob_item ;
61
- if (new_allocated <= ((~( size_t ) 0 ) / sizeof (PyObject * )))
61
+ if (new_allocated <= (PY_SIZE_MAX / sizeof (PyObject * )))
62
62
PyMem_RESIZE (items , PyObject * , new_allocated );
63
63
else
64
64
items = NULL ;
@@ -510,9 +510,9 @@ list_repeat(PyListObject *a, Py_ssize_t n)
510
510
PyObject * elem ;
511
511
if (n < 0 )
512
512
n = 0 ;
513
- size = Py_SIZE (a ) * n ;
514
- if (n && size /n != Py_SIZE (a ))
513
+ if (n > 0 && Py_SIZE (a ) > PY_SSIZE_T_MAX / n )
515
514
return PyErr_NoMemory ();
515
+ size = Py_SIZE (a ) * n ;
516
516
if (size == 0 )
517
517
return PyList_New (0 );
518
518
np = (PyListObject * ) PyList_New (size );
You can’t perform that action at this time.
0 commit comments