diff mbox

[FFmpeg-devel,2/2] avcodec/imm4: Unreference previous frame on frame size change

Message ID 20190310004100.3811-2-michael@niedermayer.cc
State Accepted
Commit 0be0197f49a5ac78c0f8be34fe66dd7657c83c23
Headers show

Commit Message

Michael Niedermayer March 10, 2019, 12:41 a.m. UTC
Fixes: Out of array access
Fixes: 13552/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IMM4_fuzzer-5767949648920576

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/imm4.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Paul B Mahol March 10, 2019, 8:15 a.m. UTC | #1
On 3/10/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: Out of array access
> Fixes:
> 13552/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IMM4_fuzzer-5767949648920576
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/imm4.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c
> index b66689acab..1a4d0decd7 100644
> --- a/libavcodec/imm4.c
> +++ b/libavcodec/imm4.c
> @@ -446,11 +446,13 @@ static int decode_frame(AVCodecContext *avctx, void
> *data,
>          return AVERROR_PATCHWELCOME;
>      }
>
> -    if (!frame->key_frame &&
> -        (avctx->width != width ||
> -         avctx->height != height)) {
> -        av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
> -        return AVERROR_INVALIDDATA;
> +    if (avctx->width  != width ||
> +        avctx->height != height) {
> +        if (!frame->key_frame) {
> +            av_log(avctx, AV_LOG_ERROR, "Frame size change is
> unsupported.\n");
> +            return AVERROR_INVALIDDATA;
> +        }
> +        av_frame_unref(s->prev_frame);
>      }

ok
Michael Niedermayer March 10, 2019, 5:01 p.m. UTC | #2
On Sun, Mar 10, 2019 at 09:15:40AM +0100, Paul B Mahol wrote:
> On 3/10/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Fixes: Out of array access
> > Fixes:
> > 13552/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IMM4_fuzzer-5767949648920576
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/imm4.c | 12 +++++++-----
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c
> > index b66689acab..1a4d0decd7 100644
> > --- a/libavcodec/imm4.c
> > +++ b/libavcodec/imm4.c
> > @@ -446,11 +446,13 @@ static int decode_frame(AVCodecContext *avctx, void
> > *data,
> >          return AVERROR_PATCHWELCOME;
> >      }
> >
> > -    if (!frame->key_frame &&
> > -        (avctx->width != width ||
> > -         avctx->height != height)) {
> > -        av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
> > -        return AVERROR_INVALIDDATA;
> > +    if (avctx->width  != width ||
> > +        avctx->height != height) {
> > +        if (!frame->key_frame) {
> > +            av_log(avctx, AV_LOG_ERROR, "Frame size change is
> > unsupported.\n");
> > +            return AVERROR_INVALIDDATA;
> > +        }
> > +        av_frame_unref(s->prev_frame);
> >      }
> 
> ok

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c
index b66689acab..1a4d0decd7 100644
--- a/libavcodec/imm4.c
+++ b/libavcodec/imm4.c
@@ -446,11 +446,13 @@  static int decode_frame(AVCodecContext *avctx, void *data,
         return AVERROR_PATCHWELCOME;
     }
 
-    if (!frame->key_frame &&
-        (avctx->width != width ||
-         avctx->height != height)) {
-        av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
-        return AVERROR_INVALIDDATA;
+    if (avctx->width  != width ||
+        avctx->height != height) {
+        if (!frame->key_frame) {
+            av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
+            return AVERROR_INVALIDDATA;
+        }
+        av_frame_unref(s->prev_frame);
     }
 
     ret = ff_set_dimensions(avctx, width, height);