Cast values to unsigned to make UBSan not trigger due to left-shifting negatives

This commit is contained in:
Ari Lemmetti 2020-03-16 19:52:34 +02:00
parent 27fe716654
commit aa0ade3f65

View file

@ -155,7 +155,8 @@ void kvz_transformskip(const encoder_control_t * const encoder, int16_t *block,i
int32_t j,k;
for (j = 0; j < block_size; j++) {
for(k = 0; k < block_size; k ++) {
coeff[j * block_size + k] = block[j * block_size + k] << shift;
// Casting back and forth to make UBSan not trigger due to left-shifting negatives
coeff[j * block_size + k] = (int16_t)((uint16_t)(block[j * block_size + k]) << shift);
}
}
}