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 9574A45ECB for ; Mon, 17 Apr 2023 11:26:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A4D1468BE0F; Mon, 17 Apr 2023 14:26:30 +0300 (EEST) Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CF16F68AF9E for ; Mon, 17 Apr 2023 14:26:24 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id E1B5240005 for ; Mon, 17 Apr 2023 11:26:23 +0000 (UTC) Date: Mon, 17 Apr 2023 13:26:23 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230417112623.GI275832@pb2> References: <20230416222518.21308-1-michael@niedermayer.cc> <9c9cb310-7c50-a400-4165-51468f5a9af5@gmail.com> MIME-Version: 1.0 In-Reply-To: <9c9cb310-7c50-a400-4165-51468f5a9af5@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="===============2229487233835249836==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============2229487233835249836== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WR+jf/RUebEcofwt" Content-Disposition: inline --WR+jf/RUebEcofwt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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_fuzz= er-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, AVPack= et *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, AVPack= et *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 that we= nt > through the av_packet_make_refcounted() in av_bsf_send_packet() that left= it > with an allocated padding buffer was fed to this bsf. yes this works too and this memleak is open since a year, its the 2nd time i submited this 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 thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 2 "100% positive feedback" - "All either got their money back or didnt compla= in" "Best seller ever, very honest" - "Seller refunded buyer after failed scam" --WR+jf/RUebEcofwt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZD0s2gAKCRBhHseHBAsP qz/PAJ9uPoUDQQ7P1oofMyDcRqDZcPmyfACfbh/hMv/yQWdAEda8HdpH1uIPOYU= =u1vg -----END PGP SIGNATURE----- --WR+jf/RUebEcofwt-- --===============2229487233835249836== 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". --===============2229487233835249836==--