From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 3328D45ED4 for ; Mon, 17 Apr 2023 11:34:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AF7ED68BE2D; Mon, 17 Apr 2023 14:34:42 +0300 (EEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C2366809C6 for ; Mon, 17 Apr 2023 14:34:36 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id A7E70E0006 for ; Mon, 17 Apr 2023 11:34:35 +0000 (UTC) Date: Mon, 17 Apr 2023 13:34:34 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230417113434.GJ275832@pb2> References: <20230416222518.21308-1-michael@niedermayer.cc> <9c9cb310-7c50-a400-4165-51468f5a9af5@gmail.com> <20230417112623.GI275832@pb2> <4ed9d14d-70f7-0f52-e87e-7c6815e75194@gmail.com> MIME-Version: 1.0 In-Reply-To: <4ed9d14d-70f7-0f52-e87e-7c6815e75194@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH 1/5] avcodec/pcm_rechunk_bsf: unref packet before putting a new one in X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: multipart/mixed; boundary="===============7494664610889684586==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============7494664610889684586== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wHh0aNzodMFDTGdO" Content-Disposition: inline --wHh0aNzodMFDTGdO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 17, 2023 at 08:28:37AM -0300, James Almer wrote: > On 4/17/2023 8:26 AM, Michael Niedermayer wrote: > > On Sun, Apr 16, 2023 at 07:57:00PM -0300, James Almer wrote: > > > On 4/16/2023 7:25 PM, Michael Niedermayer wrote: > > > > Fixes: memleak > > > > Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_BSF_PCM_RECHUNK_= fuzzer-5562089618407424 > > > >=20 > > > > 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 | 1 + > > > > 1 file changed, 1 insertion(+) > > > >=20 > > > > diff --git a/libavcodec/pcm_rechunk_bsf.c b/libavcodec/pcm_rechunk_= bsf.c > > > > index 108d9e90b99..3f43934fe9a 100644 > > > > --- a/libavcodec/pcm_rechunk_bsf.c > > > > +++ b/libavcodec/pcm_rechunk_bsf.c > > > > @@ -153,6 +153,7 @@ static int rechunk_filter(AVBSFContext *ctx, AV= Packet *pkt) > > > > } > > > > } > > > > + av_packet_unref(s->in_pkt); > > >=20 > > > This could be pointing to a bug in the above code, and unreffing here= like > > > this would result in data loss. > > >=20 > > > Does the following change also fix the memleak? > > >=20 > > > > 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, AV= Packet *pkt) > > > > av_packet_move_ref(pkt, s->in_pkt); > > > > return send_packet(s, nb_samples, pkt); > > > > } > > > > - } > > > > + } else > > > > + av_packet_unref(s->in_pkt); > > > >=20 > > > > ret =3D ff_bsf_get_packet_ref(ctx, s->in_pkt); > > > > if (ret =3D=3D AVERROR_EOF && s->out_pkt->size) { > > >=20 > > > If it does then a zero sized packet with either only side data or tha= t went > > > through the av_packet_make_refcounted() in av_bsf_send_packet() that = left it > > > with an allocated padding buffer was fed to this bsf. > >=20 > > yes this works too > > and this memleak is open since a year, its the 2nd time i submited this >=20 > Yes, i had a sense of deja vu. >=20 > > patch, last time the discussions didnt lead to any consensus on what to= do > > I hope this time some fix from someone ends up in git > >=20 > > thx >=20 > Just apply the suggested change i made above. ok thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB it is not once nor twice but times without number that the same ideas make their appearance in the world. -- Aristotle --wHh0aNzodMFDTGdO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZD0uygAKCRBhHseHBAsP q9aiAJ9Q201Hgr6fFR/ilX3x/zKa0h0EogCeMH5h7c377gz24DBKCu95HO3ifbA= =7P+A -----END PGP SIGNATURE----- --wHh0aNzodMFDTGdO-- --===============7494664610889684586== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============7494664610889684586==--