DescriptionAdd missing overflow handling to base::RandInt().
The result of RandGenerator() could return a number as high as UINT_MAX,
so casting that to int and adding it to another int will in general overflow.
Overflow is undefined behavior for signed integers, so add some type casting
to make sure this doesn't happen.
The DCHECKs in RandInt() where catching that something fishy was going on
(see bug), so as test just call RandInt() a few times with large bounds.
This test made the DCHECK reliably fire without the fix.
BUG=548375
R=thestig@chromium.org
Committed: https://crrev.com/0a3852a7502c50ae8056090207c85c424804e706
Cr-Commit-Position: refs/heads/master@{#356939}
Patch Set 1 #
Total comments: 2
Patch Set 2 : stdint hyyyyyyype #
Messages
Total messages: 10 (4 generated)
|