Skip to content

Ignore pathologically large depths such as simdjson_decode('{}', true, 1000000000) #66

@TysonAndre

Description

@TysonAndre

When the depth is both larger than the string length (guaranteeing depth limit won't be hit) and larger than a cutoff such as 100000, ignore it and use a smaller byte length value such as

  • the existing parser depth, if that is >= the string length
  • 100000, if that's sufficient
  • strlen * 2 (or the requested depth), if that's sufficient (adding extra space to make reallocations less frequent if the application calls this again with the same depth but varying string sizes)

The fact that memory is allocated for depth is different from json_decode, so users might not expect the high memory usage when attempting to avoid depth errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions