viggox / rapidjson

Automatically exported from code.google.com/p/rapidjson
MIT License
0 stars 0 forks source link

Incorrect parsing of unsigned int number types #41

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Decode number field < int32_max {"bar" : 1596811002 }
2. Decode number field > int32_max with bit 0x80000000 set {"bar" : 2740789000 }
3. Attempt to extract both fields from document as Int64()

What is the expected output? What do you see instead?
Expected output is correctly parsing to int64_t in both cases. Actual behavior 
is an Assert that the second case does not have the kInt64Flag.

Set flags in this case include kNumber, kInt, and kUint. 

What version of the product are you using? On what operating system?
0.1

Please provide any additional information below.
The error is at line 80 of rapidjson/document.h:

if (!(u & 0x80000000))
        flags_ |= kIntFlag | kInt64Flag

I've fixed it locally by changing the code to this:

GenericValue(unsigned u) : flags_(kNumberUintFlag) {
    data_.n.u64 = u; 
    if (!(u & 0x80000000))
        flags_ |= kIntFlag;
    flags_ |= kInt64Flag;
}

I didn't attach a patch due to the small scope of the change, but would be 
happy to if you'd like.

Original issue reported on code.google.com by eric....@gmail.com on 15 Oct 2012 at 8:34

GoogleCodeExporter commented 8 years ago

Original comment by milo...@gmail.com on 12 Nov 2012 at 3:52

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r72.

Original comment by milo...@gmail.com on 14 Nov 2012 at 2:36

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r73.

Original comment by milo...@gmail.com on 14 Nov 2012 at 2:38

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 152c2eff6c6c.

Original comment by milo...@gmail.com on 6 Jun 2014 at 6:04