Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Correct parsing of negative zero #146

Merged
merged 2 commits into from
Feb 13, 2016

Conversation

jcreekmore
Copy link
Contributor

If one tries to parse negative zero with Json::from_str(), computing the 2's complement of zero causes an arithmetic overflow. Check for this condition before computing the 2's complement and just return zero, since that is the 2's complement of zero anyway.
Fixes #109

The JSON specification allows one to negate zero (which should still be
zero). The current code causes a panic when negative zero is parsed.
Although negating a zero is inconsequential, the JSON specification does
allow it. Although the 2's complement of zero is zero, calculating it
causes an arithmetic overflow. Instead of panicking, check for a zero
value input and just return zero.
alexcrichton added a commit that referenced this pull request Feb 13, 2016
Correct parsing of negative zero
@alexcrichton alexcrichton merged commit 462834a into rust-lang-deprecated:master Feb 13, 2016
@alexcrichton
Copy link
Contributor

Thanks!

@jcreekmore jcreekmore deleted the 109-str-to-json branch February 13, 2016 19:59
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants