Commit 3eddfdf
committed
gh-146152: Fix memory leak in _json encoder error paths
Remove objects from markers dict on all error paths in
encoder_listencode_obj to prevent memory leaks when:
- default() raises an exception
- RecursionError occurs
- Nested encoding fails
Previously, objects were only removed on the success path,
leaving strong references in the markers dict.1 parent 91e1312 commit 3eddfdf
File tree
2 files changed
+16
-3
lines changed- Misc/NEWS.d/next/Library
- Modules
2 files changed
+16
-3
lines changedLines 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 | |
|---|---|---|---|
| |||
1627 | 1627 | | |
1628 | 1628 | | |
1629 | 1629 | | |
1630 | | - | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
1631 | 1634 | | |
1632 | 1635 | | |
1633 | 1636 | | |
1634 | 1637 | | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
1635 | 1642 | | |
1636 | | - | |
| 1643 | + | |
1637 | 1644 | | |
1638 | 1645 | | |
1639 | 1646 | | |
| |||
1642 | 1649 | | |
1643 | 1650 | | |
1644 | 1651 | | |
1645 | | - | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
1646 | 1656 | | |
1647 | 1657 | | |
1648 | 1658 | | |
| |||
0 commit comments