[FFmpeg-cvslog] avcodec/mimic: Fix undefined pointer arithmetic

Andreas Rheinhardt git at videolan.org
Fri Aug 12 20:42:09 EEST 2022


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Aug 12 00:27:41 2022 +0200| [c1b966a189f3ffef8bd48d744e644f573a218608] | committer: Andreas Rheinhardt

avcodec/mimic: Fix undefined pointer arithmetic

NULL + anything is UB.

Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c1b966a189f3ffef8bd48d744e644f573a218608
---

 libavcodec/mimic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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++) {



More information about the ffmpeg-cvslog mailing list