AK: Make JsonParser::parse_number properly parse >32bit ints

This commit is contained in:
Sahan Fernando 2020-12-20 21:07:11 +11:00 committed by Andreas Kling
parent 1a12f964d4
commit b37139e111
Notes: sideshowbarker 2024-07-19 00:42:58 +09:00

View File

@ -229,10 +229,14 @@ Optional<JsonValue> JsonParser::parse_number()
if (to_unsigned_result.has_value()) {
value = JsonValue(to_unsigned_result.value());
} else {
auto number = number_string.to_int();
auto number = number_string.to_int<i64>();
if (!number.has_value())
return {};
value = JsonValue(number.value());
if (number.value() <= AK::NumericLimits<i32>::max()) {
value = JsonValue((i32)number.value());
} else {
value = JsonValue(number.value());
}
}
#ifndef KERNEL
}