Skip to content

RecursionError on pathological input #270

Description

@Google-Autofuzz

When passing the attached input to the following script, I get an unexpected RecursionError exception, while using the latest git version of simplejson.

import sys
import simplejson

with open(sys.argv[1], 'rb') as f:
    data = f.read()
try:
    simplejson.dumps(simplejson.loads(data))
except simplejson.errors.JSONDecodeError:
    pass
except UnicodeDecodeError:
    pass
$ python simplejson_repro.py test.txt
Traceback (most recent call last):
  File "simplejson_repro.py", line 7, in <module>
    simplejson.dumps(simplejson.loads(data))
  File "/home/user/ven/lib/python3.8/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/home/user/ven/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/home/user/ven/lib/python3.8/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
RecursionError: maximum recursion depth exceeded while decoding a JSON object from a unicode string

test.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions