mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
fix overflow of integer types when writing large unsigned long longs to JSON
This commit is contained in:
parent
4b56172ac8
commit
05184a7e1a
2 changed files with 12 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
2017-11-25 Graham Lee <graham@iamleeg.com>
|
||||
|
||||
* Source/NSJSONSerialization.m: Fix for bug #12 on github. This
|
||||
makes sure that unsigned integer types are written as such,
|
||||
avoiding a potential overflow.
|
||||
|
||||
2017-11-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSArray.m: Fix for bug reported on github by zneak.
|
||||
|
|
|
@ -945,12 +945,17 @@ writeObject(id obj, NSMutableString *output, NSInteger tabs)
|
|||
{
|
||||
const char *t = [obj objCType];
|
||||
|
||||
if (strchr("cCsSiIlLqQ", *t) != 0)
|
||||
if (strchr("csilq", *t) != 0)
|
||||
{
|
||||
long long i = [(NSNumber*)obj longLongValue];
|
||||
|
||||
[output appendFormat: @"%lld", i];
|
||||
}
|
||||
else if (strchr("CSILQ", *t) != 0)
|
||||
{
|
||||
unsigned long long u = [(NSNumber *)obj unsignedLongLongValue];
|
||||
[output appendFormat: @"%llu", u];
|
||||
}
|
||||
else
|
||||
{
|
||||
[output appendFormat: @"%.17g", [(NSNumber*)obj doubleValue]];
|
||||
|
|
Loading…
Reference in a new issue