Message ID | DB6PR0101MB2214758B114E1AF1278B94258F679@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com |
---|---|
State | Accepted |
Commit | c1b966a189f3ffef8bd48d744e644f573a218608 |
Headers | show |
Series | [FFmpeg-devel] avcodec/mimic: Fix undefined pointer arithmetic | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
On Fri, Aug 12, 2022 at 02:40:43PM +0200, Andreas Rheinhardt wrote: > NULL + anything is UB. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavcodec/mimic.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) if its NULL, LGTM thx [...]
Michael Niedermayer: > On Fri, Aug 12, 2022 at 02:40:43PM +0200, Andreas Rheinhardt wrote: >> NULL + anything is UB. >> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> >> --- >> libavcodec/mimic.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) > > if its NULL, LGTM > It is (at least for the first keyframe). So I will therefore apply this. - Andreas
diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index ce5c2afd19..bcf10b7ae1 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -268,8 +268,9 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs, const int qscale = av_clip(10000 - quality, is_chroma ? 1000 : 2000, 10000) << 2; const int stride = ctx->frames[ctx->cur_index ].f->linesize[plane]; - const uint8_t *src = ctx->frames[ctx->prev_index].f->data[plane]; uint8_t *dst = ctx->frames[ctx->cur_index ].f->data[plane]; + /* src is unused for I frames; set to avoid UB pointer arithmetic. */ + const uint8_t *src = is_iframe ? dst : ctx->frames[ctx->prev_index].f->data[plane]; for (y = 0; y < ctx->num_vblocks[plane]; y++) { for (x = 0; x < ctx->num_hblocks[plane]; x++) {
NULL + anything is UB. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/mimic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)