~sircmpwn/hare-dev

1

strconv crashes when converting a lowercase hex decimal to an u64

Details
Message ID
<93a9798a-b28e-418f-94a8-ed63e6346154@yahoo.com>
DKIM signature
permerror
Download raw message
the given example crashes at runtime:

use fmt;
use strconv;

export fn main() void = {
     fmt::println(strconv::stou64("1000", strconv::base::HEX_LOWER)!)!;
};


if you use only `base::HEX` it works fine. I tried with only numerical 
values and with other valid hex such as `fa0`, both fails every time.

I get an assertion at strconv/stou.ha:22:66.

I just did a git pull on both harec and hare, so I assume this was not 
fixed yet.
Details
Message ID
<c97944d0-7b99-431b-a91a-3f518d3bb14e@spxtr.net>
In-Reply-To
<93a9798a-b28e-418f-94a8-ed63e6346154@yahoo.com> (view parent)
DKIM signature
pass
Download raw message
Thanks. I've sent a patch to fix this. You can just use base::HEX for
string->number conversions and it will handle both upper and lower case
correctly. HEX_LOWER and HEX_UPPER only matter for number->string.

Eventually I want to get rid of HEX_LOWER and HEX_UPPER entirely in
favor of a flag to the number->string functions. But for now this should
help.
Reply to thread Export thread (mbox)