Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`JSON::PullParser` overflow handling #8698

Merged
merged 4 commits into from Feb 8, 2020

Conversation

@KimBurgess
Copy link
Contributor

KimBurgess commented Jan 18, 2020

Changes behaviour of:

  • JSON::PullParser#read? to either fully read into the specified type, or return nil
  • Numeric primitive instantiation from JSON::PullParser to raise a JSON::ParseException wrapping an OverflowError in the case of overflow.

Fixes #8694

KimBurgess added 2 commits Jan 18, 2020
Captures OverfowErrors caused when attemting to read into an
incompatible integer type and wraps in a JSON::ParseException with
location context.
Adjusts behaviour to return nil in case of a numeric overflow when
reading into numeric types.
@straight-shoota

This comment has been minimized.

Copy link
Member

straight-shoota commented Jan 18, 2020

Could you please add specs for read? as well?

@RX14
RX14 approved these changes Jan 18, 2020
Copy link
Member

RX14 left a comment

There should be Int#to_i32? etc. to return nil if a cast fails. But that's another thing and i think needs compiler support.

KimBurgess added 2 commits Jan 19, 2020
Fixes and uncaught exception that would occur when reading integer
values outside the bounds of a UInt64.
@RX14
RX14 approved these changes Jan 22, 2020
@asterite asterite added this to the 0.33.0 milestone Feb 8, 2020
@asterite asterite merged commit 57fa02e into crystal-lang:master Feb 8, 2020
6 checks passed
6 checks passed
ci/circleci: check_format Your tests passed on CircleCI!
Details
ci/circleci: test_darwin Your tests passed on CircleCI!
Details
ci/circleci: test_linux Your tests passed on CircleCI!
Details
ci/circleci: test_linux32_std Your tests passed on CircleCI!
Details
ci/circleci: test_preview_mt Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.