Skip to content

fix: reject a uint that does not fit in the destination int - #210

Open
SashaMIT wants to merge 1 commit into
go-viper:mainfrom
SashaMIT:fix/uint-overflows-int
Open

SashaMIT wants to merge 1 commit into
go-viper:mainfrom
SashaMIT:fix/uint-overflows-int

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 2, 2026 •

Copy link
Copy Markdown

Summary

Decoding uint64 9223372036854775808 into an int64 stored -9223372036854775808 and returned no error. A uint larger than the destination int is now an overflow error, the same way a negative int into a uint already is. MaxInt64 still decodes. 2147483648 into an int32 is an error instead of a panic.

Test plan

  • go test -count=1 .

Decoding uint64 9223372036854775808 into an int64 stored -9223372036854775808 and returned no error. The value is now an overflow error. A uint that fits, including MaxInt64, is unchanged.
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.

1 participant