From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id C97F34FFA1 for ; Fri, 4 Jul 2025 13:56:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 4981668FA48; Fri, 4 Jul 2025 16:56:38 +0300 (EEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id A6E6D68F58D for ; Fri, 4 Jul 2025 16:56:31 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 15FF144419 for ; Fri, 4 Jul 2025 13:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1751637391; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uYjEfSJMLxKOY1UMj8Ktq7asY9v9ViXS81jdXu/defg=; b=QCRTZxWb4QLevXNc4qkULn04ADYD2qC9oEqBkNFDkFJ2/HlDkOghU00evmKLmqYfYbpjsc k/uD4SX2054qE+hOejLH3d9JSL5azpaoQWkVF+UDgb+6QH9DC75czyIeYJuhGr7F1pLlcj rwYX9byL3GHiKTqPvClfVIrydpkBlYCvBE491CD2v7kYXz4BeD7A8Hq9S5LNSPkRx0Vfuw nNRJt7akdqkT1M68kHoUmszxSAgAgTLhCCfpaeO5ioLY86sAkVP1s8GLzKaF70gn+fCXy/ YTO99A2rgEWFtI/EAoNzy/qbIUFIRi/nYwsM/uK4XRga3DR3PVlU1UR0w7zCSQ== Date: Fri, 4 Jul 2025 15:56:29 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20250704135629.GU29660@pb2> References: <20250630150114.2152464-1-502024330056@smail.nju.edu.cn> <20250630150114.2152464-3-502024330056@smail.nju.edu.cn> MIME-Version: 1.0 In-Reply-To: <20250630150114.2152464-3-502024330056@smail.nju.edu.cn> X-GND-State: clean X-GND-Score: -85 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddvfeefgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdludehmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcupfhivgguvghrmhgrhigvrhcuoehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgeqnecuggftrfgrthhtvghrnhepieegkedtjeduffejhfetgeejtdegteetgfegtdfhjefgvefhteegkeejtddvhfevnecukfhppeeguddrieeirdeiiedrvddvjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeguddrieeirdeiiedrvddvjedphhgvlhhopehlohgtrghlhhhoshhtpdhmrghilhhfrhhomhepmhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtpdhnsggprhgtphhtthhopedupdhrtghpthhtohepfhhfmhhpvghgqdguvghvvghlsehffhhmphgvghdrohhrgh X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH v4 2/3] avformat/sapenc: fix leak in sap_write_header() 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="===============4062011332632943498==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============4062011332632943498== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="lieulexE2xfG4GEr" Content-Disposition: inline --lieulexE2xfG4GEr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 30, 2025 at 11:01:13PM +0800, Lidong Yan wrote: > In sap_write_header(), ff_format_set_url() assign new allocated new_url > to contexts[i]->url but forgot to free it later. Add for loop to free > contexts[i]->url before av_free(context). >=20 > To prevent from writing free-for-loop in every return point, replace > `return 0` with `ret =3D 0` so normal execution can fall through cleanup > code. >=20 > Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> > --- > libavformat/sapenc.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c > index 87a834a8d8..0882690ba5 100644 > --- a/libavformat/sapenc.c > +++ b/libavformat/sapenc.c > @@ -244,11 +244,15 @@ static int sap_write_header(AVFormatContext *s) > goto fail; > } > =20 > - return 0; > + ret =3D 0; > =20 av_freep(&contexts); =2E.. if (sap->ann_size > sap->ann_fd->max_packet_size) { av_log(s, AV_LOG_ERROR, "Announcement too large to send in one " "packet\n"); goto fail; > fail: > + for (i =3D 0; i < s->nb_streams; i++) > + if (contexts[i]) > + av_free(contexts[i]->url); contexts will be NULL so i would assume contexts[i] will segfault thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Rewriting code that is poorly written but fully understood is good. Rewriting code that one doesnt understand is a sign that one is less smart than the original author, trying to rewrite it will not make it better. --lieulexE2xfG4GEr Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCaGfdigAKCRBhHseHBAsP q9n7AJ0VMNu9Do4IbLLbFH1WyQ5Zea6uSACePxmvJjFGZ10H47qInMclTSNEGNA= =5YOg -----END PGP SIGNATURE----- --lieulexE2xfG4GEr-- --===============4062011332632943498== 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". --===============4062011332632943498==--