Commit cf6c1f3
committed
gh-158345: Don't grow an array when append, insert or extend overflows
ins1() checks the item with setitem(self, -1, v) before growing the
array, but since gh-156865 the 'e', 'f' and 'Zf' setters detect an
overflow only when they pack into the array, which that call skips.
The array then grew by one item before the real store failed.
Pack into a local buffer before the bounds check, so the check call
fails too, and copy the result into the array only for a real index.1 parent 89eee1f commit cf6c1f3
3 files changed
Lines changed: 40 additions & 15 deletions
File tree
- Lib/test
- Misc/NEWS.d/next/Library
- Modules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1612 | 1612 | | |
1613 | 1613 | | |
1614 | 1614 | | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
1615 | 1622 | | |
1616 | 1623 | | |
1617 | 1624 | | |
1618 | 1625 | | |
1619 | 1626 | | |
1620 | 1627 | | |
1621 | 1628 | | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
1622 | 1635 | | |
1623 | 1636 | | |
1624 | 1637 | | |
| |||
1649 | 1662 | | |
1650 | 1663 | | |
1651 | 1664 | | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
1652 | 1672 | | |
1653 | 1673 | | |
1654 | 1674 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
585 | 585 | | |
586 | 586 | | |
587 | 587 | | |
| 588 | + | |
588 | 589 | | |
589 | 590 | | |
590 | 591 | | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
591 | 595 | | |
592 | 596 | | |
593 | 597 | | |
594 | 598 | | |
595 | | - | |
596 | | - | |
| 599 | + | |
597 | 600 | | |
598 | 601 | | |
599 | 602 | | |
| |||
608 | 611 | | |
609 | 612 | | |
610 | 613 | | |
| 614 | + | |
611 | 615 | | |
612 | 616 | | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
613 | 620 | | |
614 | 621 | | |
615 | 622 | | |
616 | 623 | | |
617 | | - | |
618 | | - | |
| 624 | + | |
619 | 625 | | |
620 | 626 | | |
621 | 627 | | |
| |||
653 | 659 | | |
654 | 660 | | |
655 | 661 | | |
| 662 | + | |
656 | 663 | | |
657 | 664 | | |
658 | 665 | | |
659 | 666 | | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
660 | 672 | | |
661 | 673 | | |
662 | 674 | | |
663 | 675 | | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
| 676 | + | |
675 | 677 | | |
676 | 678 | | |
677 | 679 | | |
| |||
0 commit comments