Fix UBSan errors (left shift of negative value, left shift overflows int)

BUG=chromium:603498

Review-Url: https://codereview.webrtc.org/1979973003
Cr-Commit-Position: refs/heads/master@{#12787}
This commit is contained in:
kwiberg
2016-05-18 02:20:28 -07:00
committed by Commit bot
parent 60200d1094
commit 89f237cedc
2 changed files with 7 additions and 7 deletions

View File

@ -214,10 +214,10 @@ int WebRtcIsac_DecHistOneStepMulti(int *data, /* output: data vector */
if (streamdata->stream_index == 0) /* first time decoder is called for this stream */ if (streamdata->stream_index == 0) /* first time decoder is called for this stream */
{ {
/* read first word from bytestream */ /* read first word from bytestream */
streamval = *stream_ptr << 24; streamval = (uint32_t)(*stream_ptr) << 24;
streamval |= *++stream_ptr << 16; streamval |= (uint32_t)(*++stream_ptr) << 16;
streamval |= *++stream_ptr << 8; streamval |= (uint32_t)(*++stream_ptr) << 8;
streamval |= *++stream_ptr; streamval |= (uint32_t)(*++stream_ptr);
} else { } else {
streamval = streamdata->streamval; streamval = streamdata->streamval;
} }

View File

@ -162,9 +162,9 @@ static void FindInvArSpec(const int16_t* ARCoefQ12,
} }
for (k = 0; k < FRAMESAMPLES / 8; k++) { for (k = 0; k < FRAMESAMPLES / 8; k++) {
CurveQ16[FRAMESAMPLES_QUARTER - 1 - k] = CurveQ16[k] - int32_t diff_q16_shifted = (int32_t)((uint32_t)(diffQ16[k]) << shftVal);
(diffQ16[k] << shftVal); CurveQ16[FRAMESAMPLES_QUARTER - 1 - k] = CurveQ16[k] - diff_q16_shifted;
CurveQ16[k] += diffQ16[k] << shftVal; CurveQ16[k] += diff_q16_shifted;
} }
} }