strconv: fix bounds check bug, discovered by the equivalent of ./v -g -force-bounds-checking test vlib/toml/ (thanks to tankf33der)

This commit is contained in:
Delyan Angelov 2025-07-23 15:38:04 +03:00
parent 2eacc6fadb
commit 5c56909547
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -46,7 +46,7 @@ pub fn common_parse_uint2(s string, _base int, _bit_size int) (u64, int) {
// Look for octal, binary and hex prefix.
base = 10
if s[0] == `0` {
ch := s[1] | 32
ch := if s.len > 1 { s[1] | 32 } else { `0` }
if s.len >= 3 {
if ch == `b` {
base = 2