Repository navigation
Commit 9a52edb
After a failed `del b[:n]`, `bytearray_setslice_linear()` moved `ob_start` back, but `bytearray_resize_storage()` had already realigned the data and reset `ob_start`, so the bytearray then started `n` bytes before its buffer. The front-delete path now moves `ob_start` and the size before the shrinking resize and no longer restores anything, so a failed shrink leaves the bytes removed and the larger block in place, raising `MemoryError` as the non-front path already does. The checks in `bytearray_resize_lock_held()` are split from a new `bytearray_resize_unchecked()` so the slice code can call it directly without changing other callers, and the non-front failure path now writes the trailing null byte it was missing.
Fixes #160303
ANT-2026-QRZ6IDTC
<!-- gh-issue-number: gh-160303 -->
* Issue: gh-160303
<!-- /gh-issue-number -->
(cherry picked from commit 35e2c5a)
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
1 parent f2a3355 commit 9a52edb
3 files changed
Lines changed: 91 additions & 38 deletions
File tree
- Lib/test
- Misc/NEWS.d/next/Core_and_Builtins
- Objects
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1590 | 1590 | | |
1591 | 1591 | | |
1592 | 1592 | | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
1593 | 1597 | | |
1594 | 1598 | | |
1595 | 1599 | | |
| |||
1616 | 1620 | | |
1617 | 1621 | | |
1618 | 1622 | | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
1619 | 1650 | | |
1620 | 1651 | | |
1621 | 1652 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
263 | 270 | | |
264 | | - | |
| 271 | + | |
265 | 272 | | |
266 | | - | |
267 | | - | |
| 273 | + | |
| 274 | + | |
268 | 275 | | |
269 | 276 | | |
| 277 | + | |
| 278 | + | |
270 | 279 | | |
271 | 280 | | |
272 | 281 | | |
273 | 282 | | |
274 | 283 | | |
275 | 284 | | |
276 | 285 | | |
277 | | - | |
278 | | - | |
279 | 286 | | |
280 | 287 | | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | 288 | | |
295 | 289 | | |
296 | 290 | | |
| |||
342 | 336 | | |
343 | 337 | | |
344 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
345 | 363 | | |
346 | 364 | | |
347 | 365 | | |
| |||
615 | 633 | | |
616 | 634 | | |
617 | 635 | | |
618 | | - | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
619 | 639 | | |
| 640 | + | |
620 | 641 | | |
621 | 642 | | |
622 | 643 | | |
623 | 644 | | |
624 | 645 | | |
625 | 646 | | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
626 | 652 | | |
627 | 653 | | |
628 | 654 | | |
| |||
633 | 659 | | |
634 | 660 | | |
635 | 661 | | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
651 | 672 | | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | 673 | | |
657 | 674 | | |
658 | 675 | | |
| |||
0 commit comments