mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
gh-125010: Fix use-after-free
in AST repr()
(#125015)
This commit is contained in:
parent
3fc673e97d
commit
a1be83dae3
3 changed files with 7 additions and 2 deletions
|
@ -789,6 +789,13 @@ class AST_Tests(unittest.TestCase):
|
|||
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."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue