Fix bugs highlighted in tests

This commit is contained in:
Maya Warrier 2023-12-12 22:35:58 -05:00
parent 01e8c50a33
commit a30fe866f6
2 changed files with 2 additions and 2 deletions

View File

@ -468,7 +468,7 @@ from_chars_result_t<UC> parse_int_string(UC const* p, UC const* pend, T& value,
uint64_t i = 0; uint64_t i = 0;
while (p != pend) { while (p != pend) {
uint8_t digit = ch_to_digit(*p); uint8_t digit = ch_to_digit(*p);
if (digit > base) { if (digit >= base) {
break; break;
} }
i = uint64_t(base) * i + digit; // might overflow, check this later i = uint64_t(base) * i + digit; // might overflow, check this later

View File

@ -242,7 +242,7 @@ from_chars_result_t<UC> from_chars(UC const* first, UC const* last, T& value, in
first++; first++;
} }
#endif #endif
if (first == last) { if (first == last || base < 2 || base > 36) {
answer.ec = std::errc::invalid_argument; answer.ec = std::errc::invalid_argument;
answer.ptr = first; answer.ptr = first;
return answer; return answer;