File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ Core and Builtins
1313- Issue #27507: Add integer overflow check in bytearray.extend(). Patch by
1414 Xiang Zhang.
1515
16+ - Issue #27581: Don't rely on wrapping for overflow check in
17+ PySequence_Tuple(). Patch by Xiang Zhang.
18+
1619- Issue #27419: Standard __import__() no longer look up "__import__" in globals
1720 or builtins for importing submodules or "from import". Fixed a crash if
1821 raise a warning about unabling to resolve package from __spec__ or
Original file line number Diff line number Diff line change @@ -1747,21 +1747,22 @@ PySequence_Tuple(PyObject *v)
17471747 break ;
17481748 }
17491749 if (j >= n ) {
1750- Py_ssize_t oldn = n ;
1750+ size_t newn = ( size_t ) n ;
17511751 /* The over-allocation strategy can grow a bit faster
17521752 than for lists because unlike lists the
17531753 over-allocation isn't permanent -- we reclaim
17541754 the excess before the end of this routine.
17551755 So, grow by ten and then add 25%.
17561756 */
1757- n += 10 ;
1758- n += n >> 2 ;
1759- if (n < oldn ) {
1757+ newn += 10u ;
1758+ newn += newn >> 2 ;
1759+ if (newn > PY_SSIZE_T_MAX ) {
17601760 /* Check for overflow */
17611761 PyErr_NoMemory ();
17621762 Py_DECREF (item );
17631763 goto Fail ;
17641764 }
1765+ n = (Py_ssize_t )newn ;
17651766 if (_PyTuple_Resize (& result , n ) != 0 ) {
17661767 Py_DECREF (item );
17671768 goto Fail ;
You can’t perform that action at this time.
0 commit comments