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?
1010Core and Builtins
1111-----------------
1212
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+
1317- Issue #12802: the Windows error ERROR_DIRECTORY (numbered 267) is now
1418 mapped to POSIX errno ENOTDIR (previously EINVAL).
1519
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
5858 if (newsize == 0 )
5959 new_allocated = 0 ;
6060 items = self -> ob_item ;
61- if (new_allocated <= ((~( size_t ) 0 ) / sizeof (PyObject * )))
61+ if (new_allocated <= (PY_SIZE_MAX / sizeof (PyObject * )))
6262 PyMem_RESIZE (items , PyObject * , new_allocated );
6363 else
6464 items = NULL ;
@@ -510,9 +510,9 @@ list_repeat(PyListObject *a, Py_ssize_t n)
510510 PyObject * elem ;
511511 if (n < 0 )
512512 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 )
515514 return PyErr_NoMemory ();
515+ size = Py_SIZE (a ) * n ;
516516 if (size == 0 )
517517 return PyList_New (0 );
518518 np = (PyListObject * ) PyList_New (size );
You can’t perform that action at this time.
0 commit comments