aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-04-25 01:54:17 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-07-08 19:45:46 +0200
commit2901299610c05522bbaf9ba630ef8bf0843d19af (patch)
tree2579bf8e82a668523937a0e7ab5a82a5d742f836
parent83e870beb80b1170f81910793c1347d3ae900878 (diff)
downloadffmpeg-2901299610c05522bbaf9ba630ef8bf0843d19af.tar.gz
avcodec/elsdec: Fix memleaks
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 <michael@niedermayer.cc> (cherry picked from commit 0bd0401336df4e4ca7f3da6a7e226904fd7d5add) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/elsdec.c8
-rw-r--r--libavcodec/g2meet.c1
2 files changed, 4 insertions, 5 deletions
diff --git a/libavcodec/elsdec.c b/libavcodec/elsdec.c
index 4797965457..cb0e9c6534 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)
@@ -391,12 +391,10 @@ unsigned ff_els_decode_unsigned(ElsDecCtx *ctx, ElsUnsignedRung *ur)
if (ur->rung_list_size <= (ur->avail_index + 2) * sizeof(ElsRungNode)) {
// remember rung_node position
ptrdiff_t pos = rung_node - ur->rem_rung_list;
- ur->rem_rung_list = av_realloc(ur->rem_rung_list,
+ ctx->err = av_reallocp(&ur->rem_rung_list,
ur->rung_list_size +
RUNG_SPACE);
- if (!ur->rem_rung_list) {
- av_free(ur->rem_rung_list);
- ctx->err = AVERROR(ENOMEM);
+ if (ctx->err < 0) {
return 0;
}
memset((uint8_t *) ur->rem_rung_list + ur->rung_list_size, 0,
diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index b0af3ec046..f5b053d0d6 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -926,6 +926,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;
}