Fixes the following FATE-tests when run under Clang-UBSan: ffmpeg-loopback-decoding, lavf-mxf_ffv1, vsynth{1,2,3,_lena}-ffv1-v{0,2}, vsynth1-ffv{1,2,3,_lena}, vsynth{1,2,3,_lena}-ffv1-v3-yuv{420p,422p10,444p16}
Unified · Split
| @@ -281,6 +281,8 @@ static int encode_plane(FFV1Context *f, FFV1SliceContext *sc, · 280 unmodified lines | ||
| 281 | 281 | int16_t *sample[3]; |
| 282 | 282 | sc->run_index = 0; |
| 283 | 283 | |
| 284 | + sample[2] = sc->sample_buffer; // dummy to avoid UB pointer arithmetic | |
| 285 | + | |
| 284 | 286 | memset(sc->sample_buffer, 0, ring_size * (w + 6) * sizeof(*sc->sample_buffer)); |
| 285 | 287 | |
| 286 | 288 | for (y = 0; y < h; y++) { |
| @@ -1509,6 +1511,9 @@ static int encode_float32_rgb_frame(FFV1Context *f, FFV1SliceContext *sc, · 1222 unmodified lines | ||
| 1509 | 1511 | |
| 1510 | 1512 | sc->run_index = 0; |
| 1511 | 1513 | |
| 1514 | + for (int p = 0; p < MAX_PLANES; ++p) | |
| 1515 | + sample[p][2] = sc->sample_buffer32; // dummy to avoid UB pointer arithmetic | |
| 1516 | + | |
| 1512 | 1517 | memset(RENAME(sc->sample_buffer), 0, ring_size * MAX_PLANES * |
| 1513 | 1518 | (w + 6) * sizeof(*RENAME(sc->sample_buffer))); |
| 1514 | 1519 | |
| @@ -25,7 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | static av_always_inline int |
| 26 | 26 | RENAME(encode_line)(FFV1Context *f, FFV1SliceContext *sc, |
| 27 | 27 | void *logctx, |
| 28 | − int w, TYPE *sample[3], int plane_index, int bits, | |
| 28 | + int w, TYPE *const sample[3], int plane_index, int bits, | |
| 29 | 29 | int ac, int pass1) |
| 30 | 30 | { |
| 31 | 31 | PlaneContext *const p = &sc->plane[plane_index]; |
| @@ -189,6 +189,9 @@ static int RENAME(encode_rgb_frame)(FFV1Context *f, FFV1SliceContext *sc, · 157 unmodified lines | ||
| 189 | 189 | |
| 190 | 190 | sc->run_index = 0; |
| 191 | 191 | |
| 192 | + for (int p = 0; p < MAX_PLANES; ++p) | |
| 193 | + sample[p][2] = RENAME(sc->sample_buffer); | |
| 194 | + | |
| 192 | 195 | memset(RENAME(sc->sample_buffer), 0, ring_size * MAX_PLANES * |
| 193 | 196 | (w + 6) * sizeof(*RENAME(sc->sample_buffer))); |
| 194 | 197 | |