When `off' is 0, `0x537F6103 << 32' in the following expression invokes undefined behavior, the result of which is not necessarily 0. (0x537F6103 >> (off * 8)) | (0x537F6103 << (32 - (off * 8))) Avoid oversized shifting. CC: libav-stable@libav.org
Unified · Split
| @@ -163,7 +163,10 @@ static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes) · 162 unmodified lines | |||
| 163 | 163 | ||
| 164 | off = (intptr_t)input & 3; | 164 | off = (intptr_t)input & 3; |
| 165 | buf = (const uint32_t *)(input - off); | 165 | buf = (const uint32_t *)(input - off); |
| 166 | c = av_be2ne32((0x537F6103 >> (off * 8)) | (0x537F6103 << (32 - (off * 8)))); | 166 | if (off) |
| 167 | c = av_be2ne32((0x537F6103U >> (off * 8)) | (0x537F6103U << (32 - (off * 8)))); | ||
| 168 | else | ||
| 169 | c = av_be2ne32(0x537F6103U); | ||
| 167 | bytes += 3 + off; | 170 | bytes += 3 + off; |
| 168 | for (i = 0; i < bytes / 4; i++) | 171 | for (i = 0; i < bytes / 4; i++) |
| 169 | output[i] = c ^ buf[i]; | 172 | output[i] = c ^ buf[i]; |