Folly parseJson doesn't handle minInt properly
authorBo You <byou@fb.com>
Mon, 27 Jun 2016 16:17:21 +0000 (09:17 -0700)
committerFacebook Github Bot 8 <facebook-github-bot-8-bot@fb.com>
Mon, 27 Jun 2016 16:23:22 +0000 (09:23 -0700)
commit6dbd5d0641f727d50995921e2dd188b67caf2bd0
tree4db2b3514e5c50cd81fb9d092f5ef3e078403ae4
parent1ce31b9aab2dbf6d86c6f6df39374a7334d81f43
Folly parseJson doesn't handle minInt properly

Summary:
Right now in ##parseNumber## in ##folly/json.cpp##, when a negative number is provided, both the minus sign and the digits are stored in the variable ##integral##: https://fburl.com/362938516.

This causes problem when the exact min int is provided (-9223372036854775808). Because now ##integral.size()## equals 20 (including the minus sign), which is greater than ##maxIntLen## (which is 19). We need to handle negatives separately to get the correct result.

Reviewed By: yfeldblum

Differential Revision: D3479054

fbshipit-source-id: 15c782962a5f5ee845a2a18f2145c7695ec2d546
folly/json.cpp
folly/test/JsonTest.cpp