Fixes: 6798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G2M_fuzzer-5135899701542912
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> --- libavcodec/elsdec.c | 10 ++++++---- libavcodec/g2meet.c | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/elsdec.c b/libavcodec/elsdec.c index 4797965457..8327662b4b 100644 --- a/libavcodec/elsdec.c +++ b/libavcodec/elsdec.c @@ -271,7 +271,7 @@ void ff_els_decoder_init(ElsDecCtx *ctx, const uint8_t *in, size_t data_size) void ff_els_decoder_uninit(ElsUnsignedRung *rung) { - av_free(rung->rem_rung_list); + av_freep(&rung->rem_rung_list); } static int els_import_byte(ElsDecCtx *ctx) @@ -389,16 +389,18 @@ unsigned ff_els_decode_unsigned(ElsDecCtx *ctx, ElsUnsignedRung *ur) else { if (!rung_node->next_index) { if (ur->rung_list_size <= (ur->avail_index + 2) * sizeof(ElsRungNode)) { + void *ptr_tmp; // remember rung_node position ptrdiff_t pos = rung_node - ur->rem_rung_list; - ur->rem_rung_list = av_realloc(ur->rem_rung_list, + ptr_tmp = av_realloc(ur->rem_rung_list, ur->rung_list_size + RUNG_SPACE); - if (!ur->rem_rung_list) { - av_free(ur->rem_rung_list); + if (!ptr_tmp) { + av_freep(&ur->rem_rung_list); ctx->err = AVERROR(ENOMEM); return 0; } + ur->rem_rung_list = ptr_tmp; memset((uint8_t *) ur->rem_rung_list + ur->rung_list_size, 0, RUNG_SPACE); ur->rung_list_size += RUNG_SPACE; diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c index a46157218f..b409dae813 100644 --- a/libavcodec/g2meet.c +++ b/libavcodec/g2meet.c @@ -927,6 +927,7 @@ static int epic_jb_decode_tile(G2MContext *c, int tile_x, int tile_y, if (c->ec.els_ctx.err != 0) { av_log(avctx, AV_LOG_ERROR, "ePIC: couldn't decode transparency pixel!\n"); + ff_els_decoder_uninit(&c->ec.unsigned_rung); return AVERROR_INVALIDDATA; } -- 2.17.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel