From 1440bf15e2b911cb41b88f2340878ca596d987c0 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 29 Mar 2022 23:24:59 +0200 Subject: [PATCH] avcodec/pcm_rechunk_bsf: unref packet before putting a new one in Fixes: memleak Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_BSF_PCM_RECHUNK_fuzzer-5562089618407424 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/pcm_rechunk_bsf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/pcm_rechunk_bsf.c b/libavcodec/pcm_rechunk_bsf.c index 108d9e90b9..032f914916 100644 --- a/libavcodec/pcm_rechunk_bsf.c +++ b/libavcodec/pcm_rechunk_bsf.c @@ -151,7 +151,8 @@ static int rechunk_filter(AVBSFContext *ctx, AVPacket *pkt) av_packet_move_ref(pkt, s->in_pkt); return send_packet(s, nb_samples, pkt); } - } + } else + av_packet_unref(s->in_pkt); ret = ff_bsf_get_packet_ref(ctx, s->in_pkt); if (ret == AVERROR_EOF && s->out_pkt->size) {