mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +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
|
@ -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…
Add table
Add a link
Reference in a new issue