Skip to content

3.11 ast.parse on fuzzed string: SystemError: Negative size passed to PyUnicode_New #135426

Closed as not planned
@nedbat

Description

@nedbat

Bug report

Bug description:

crash.py:

import ast

ast.parse('f""""{5\nclass""\ta:""0"""')

On 3.11.13:

% python3.11 crash.py
Traceback (most recent call last):
  File "/Users/ned/coverage/trunk/crash.py", line 3, in <module>
    ast.parse('f""""{5\nclass""\ta:""0"""')
  File "/usr/local/pyenv/pyenv/versions/3.11.13/lib/python3.11/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: Negative size passed to PyUnicode_New

3.12 and up report SyntaxError: '{' was never closed

This was found by oss-fuzz and reported to coverage.py: https://issues.oss-fuzz.com/issues/424242613

CPython versions tested on:

3.11, 3.12, 3.13, 3.14

Operating systems tested on:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions