diff mbox

[FFmpeg-devel,2/2] avcodec/jvdec: Use ff_get_buffer() when the content is not reused

Message ID 20190503233838.29823-2-michael@niedermayer.cc
State Accepted
Commit 09edcd35726c9ebea8a175b54dfe05483f7154f2
Headers show

Commit Message

Michael Niedermayer May 3, 2019, 11:38 p.m. UTC
Fixes: Timeout (11sec -> 5sec)
Fixes: 14473/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JV_fuzzer-5761630857592832

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

Comments

Peter Ross May 4, 2019, 1:30 a.m. UTC | #1
On Sat, May 04, 2019 at 01:38:38AM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (11sec -> 5sec)
> Fixes: 14473/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JV_fuzzer-5761630857592832
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/jvdec.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 

looks good. please apply.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Michael Niedermayer May 4, 2019, 6:18 p.m. UTC | #2
On Sat, May 04, 2019 at 11:30:38AM +1000, Peter Ross wrote:
> On Sat, May 04, 2019 at 01:38:38AM +0200, Michael Niedermayer wrote:
> > Fixes: Timeout (11sec -> 5sec)
> > Fixes: 14473/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JV_fuzzer-5761630857592832
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/jvdec.c | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> > 
> 
> looks good. please apply.

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/jvdec.c b/libavcodec/jvdec.c
index 4337d5681e..b06e7cf2bf 100644
--- a/libavcodec/jvdec.c
+++ b/libavcodec/jvdec.c
@@ -163,13 +163,14 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
             av_log(avctx, AV_LOG_ERROR, "video size %d invalid\n", video_size);
             return AVERROR_INVALIDDATA;
         }
-        if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
-            return ret;
 
         if (video_type == 0 || video_type == 1) {
             GetBitContext gb;
             init_get_bits(&gb, buf, 8 * video_size);
 
+            if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
+                return ret;
+
             if (avctx->height/8 * (avctx->width/8) > 4 * video_size) {
                 av_log(avctx, AV_LOG_ERROR, "Insufficient input data for dimensions\n");
                 return AVERROR_INVALIDDATA;
@@ -184,6 +185,11 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
             buf += video_size;
         } else if (video_type == 2) {
             int v = *buf++;
+
+            av_frame_unref(s->frame);
+            if ((ret = ff_get_buffer(avctx, s->frame, AV_GET_BUFFER_FLAG_REF)) < 0)
+                return ret;
+
             for (j = 0; j < avctx->height; j++)
                 memset(s->frame->data[0] + j * s->frame->linesize[0],
                        v, avctx->width);