Skip to content

parse: honor target bit size for integer strings - #363

Open
team-humaki wants to merge 1 commit into
spf13:masterfrom
team-humaki:parse-int-bitsize
Open

team-humaki wants to merge 1 commit into
spf13:masterfrom
team-humaki:parse-int-bitsize

Conversation

@team-humaki

Copy link
Copy Markdown

parseInt/parseUint called strconv.ParseInt/ParseUint with bitSize 0, so a string that fits in a platform int but not the destination type wrapped and returned err == nil. Overflow past int64 already failed, so the string path disagreed with itself depending on width.

Pass the destination bit size. ToInt8E("128"), ToInt8E("-129"), and ToUint8E("256") now error; in-range values are unchanged.

Fixes #260

ParseInt/ParseUint used bitSize 0 (platform int), so values that
fit in int but not int8/uint8/etc wrapped with a nil error.
Strings that overflow int64 already failed. Pass the destination
width so the two paths agree.

Fixes spf13#260
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent out of bounds errors

2 participants