Commit 13d48c42 authored by James Zern's avatar James Zern

acm_random,Rand9Signed: correct cast

convert the random value to int16 before subtracting 256 from it; quiets
a ubsan (sanitize=integer) warning

BUG=webm:1225

Change-Id: Ibc2c5a21f30e112bd6c180f7d6a033327c38d0df
parent 0ba9b299
......@@ -35,7 +35,7 @@ class ACMRandom {
int16_t Rand9Signed(void) {
// Use 9 bits: values between 255 (0x0FF) and -256 (0x100).
const uint32_t value = random_.Generate(512);
return static_cast<int16_t>(value - 256);
return static_cast<int16_t>(value) - 256;
}
uint8_t Rand8(void) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment