FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-125010: Fix `use-after-free` in AST `repr()` by tomasr8 · Pull Request #125015 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .py  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 7 additions & 0 deletions Lib/test/test_ast/test_ast.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,13 @@ def test_repr(self) -> None:
with self.subTest(test_input=test):
self.assertEqual(repr(ast.parse(test)), snapshot)

def test_repr_large_input_crash(self):
# gh-125010: Fix use-after-free in ast repr()
source = "0x0" + "e" * 10_000
with self.assertRaisesRegex(ValueError,
r"Exceeds the limit \(\d+ digits\)"):
repr(ast.Constant(value=eval(source)))


class CopyTests(unittest.TestCase):
"""Test copying and pickling AST nodes."""
Expand Down
1 change: 0 additions & 1 deletion Parser/asdl_c.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,6 @@ def visitModule(self, mod):

if (!value_repr) {
Py_DECREF(name);
Py_DECREF(value);
goto error;
}

Expand Down
1 change: 0 additions & 1 deletion Python/Python-ast.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.


Back | FazBrowse Home | New Git URL