avcodec/flashsv: Clear pointers

Fixes: Use after free
Fixes: 47399/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLASHSV2_fuzzer-5718646686613504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
release/5.1
Michael Niedermayer 3 years ago
parent 4ff654e030
commit b418ad75c2
  1. 4
      libavcodec/flashsv.c

@ -350,6 +350,9 @@ static int flashsv_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
if (err < 0) if (err < 0)
return err; return err;
s->keyframedata = avpkt->data; s->keyframedata = avpkt->data;
if (s->blocks)
memset(s->blocks, 0, (v_blocks + !!v_part) * (h_blocks + !!h_part) *
sizeof(s->blocks[0]));
} }
if(s->ver == 2 && !s->blocks) if(s->ver == 2 && !s->blocks)
s->blocks = av_mallocz((v_blocks + !!v_part) * (h_blocks + !!h_part) * s->blocks = av_mallocz((v_blocks + !!v_part) * (h_blocks + !!h_part) *
@ -558,6 +561,7 @@ static av_cold int flashsv2_decode_end(AVCodecContext *avctx)
FlashSVContext *s = avctx->priv_data; FlashSVContext *s = avctx->priv_data;
av_buffer_unref(&s->keyframedata_buf); av_buffer_unref(&s->keyframedata_buf);
s->keyframedata = NULL;
av_freep(&s->blocks); av_freep(&s->blocks);
av_freep(&s->keyframe); av_freep(&s->keyframe);
flashsv_decode_end(avctx); flashsv_decode_end(avctx);

Loading…
Cancel
Save