mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
Fix bugs highlighted in tests
This commit is contained in:
parent
01e8c50a33
commit
a30fe866f6
@ -468,7 +468,7 @@ from_chars_result_t<UC> parse_int_string(UC const* p, UC const* pend, T& value,
|
||||
uint64_t i = 0;
|
||||
while (p != pend) {
|
||||
uint8_t digit = ch_to_digit(*p);
|
||||
if (digit > base) {
|
||||
if (digit >= base) {
|
||||
break;
|
||||
}
|
||||
i = uint64_t(base) * i + digit; // might overflow, check this later
|
||||
|
||||
@ -242,7 +242,7 @@ from_chars_result_t<UC> from_chars(UC const* first, UC const* last, T& value, in
|
||||
first++;
|
||||
}
|
||||
#endif
|
||||
if (first == last) {
|
||||
if (first == last || base < 2 || base > 36) {
|
||||
answer.ec = std::errc::invalid_argument;
|
||||
answer.ptr = first;
|
||||
return answer;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user