mirror of
https://github.com/json-c/json-c.git
synced 2026-03-28 09:29:06 +08:00
Initialize errno before calling sscanf in json_parse_int64() so parsing valid numbers after parsing an out of range number works.
This commit is contained in:
@@ -80,6 +80,9 @@ int main()
|
||||
strcpy(buf, "-21474836480"); // INT32_MIN * 10
|
||||
checkit(buf);
|
||||
|
||||
strcpy(buf, "9223372036854775806"); // INT64_MAX - 1
|
||||
checkit(buf);
|
||||
|
||||
strcpy(buf, "9223372036854775807"); // INT64_MAX
|
||||
checkit(buf);
|
||||
|
||||
@@ -92,6 +95,9 @@ int main()
|
||||
strcpy(buf, "-9223372036854775809"); // INT64_MIN - 1
|
||||
checkit(buf);
|
||||
|
||||
strcpy(buf, "18446744073709551614"); // UINT64_MAX - 1
|
||||
checkit(buf);
|
||||
|
||||
strcpy(buf, "18446744073709551615"); // UINT64_MAX
|
||||
checkit(buf);
|
||||
|
||||
@@ -101,5 +107,9 @@ int main()
|
||||
strcpy(buf, "-18446744073709551616"); // -UINT64_MAX
|
||||
checkit(buf);
|
||||
|
||||
// Ensure we can still parse valid numbers after parsing out of range ones.
|
||||
strcpy(buf, "123");
|
||||
checkit(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,10 +17,13 @@ buf=-2147483647 parseit=0, value=-2147483647
|
||||
buf=-2147483648 parseit=0, value=-2147483648
|
||||
buf=-2147483649 parseit=0, value=-2147483649
|
||||
buf=-21474836480 parseit=0, value=-21474836480
|
||||
buf=9223372036854775806 parseit=0, value=9223372036854775806
|
||||
buf=9223372036854775807 parseit=0, value=9223372036854775807
|
||||
buf=9223372036854775808 parseit=0, value=9223372036854775807
|
||||
buf=-9223372036854775808 parseit=0, value=-9223372036854775808
|
||||
buf=-9223372036854775809 parseit=0, value=-9223372036854775808
|
||||
buf=18446744073709551614 parseit=0, value=9223372036854775807
|
||||
buf=18446744073709551615 parseit=0, value=9223372036854775807
|
||||
buf=18446744073709551616 parseit=0, value=9223372036854775807
|
||||
buf=-18446744073709551616 parseit=0, value=-9223372036854775808
|
||||
buf=123 parseit=0, value=123
|
||||
|
||||
Reference in New Issue
Block a user