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 156D94F7BD for ; Mon, 23 Jun 2025 12:09:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 7912268E2B9; Mon, 23 Jun 2025 15:09:33 +0300 (EEST) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 8E83068E114 for ; Mon, 23 Jun 2025 15:09:26 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id D36C343A13 for ; Mon, 23 Jun 2025 12:09:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1750680566; 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=/UizS1kL5fy217ehwPKLgy6TiNyQeYThj/L8tYBK7aQ=; b=KuBOHNX83soazRea5SL8+gpsESL1SfWePfFsBUOhnbY5ZbBntV0hV8hxSLzMcLePZ5Ouv2 mGbffaDMKDTXZv4aJEEw0yXblEjA2E9/Bx1ebv+34qUd8EYpphGm5b30uaSrA3NbO6ntup b6+GK2mhS5dHaeQJ6zLqcjfZIS2DRGpxd9/F1FHzvp6VYeFqVMTN3pjv6n29fKF4a38EmM +XAfohXq00CULg9zBVx8fieFNQUzUiqChPfv4SeKw8Nqgq5M42yaaMfw9IAi/K46JbvcuH SUS9wUfJ2NkvigEYliYbekXpIviOIVPbDpIrAQsM40IYyWPv74AgKUu+bIwFKA== Date: Mon, 23 Jun 2025 14:09:24 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20250623120924.GE29660@pb2> References: <20250617141416.950239-1-502024330056@smail.nju.edu.cn> <20250617141416.950239-5-502024330056@smail.nju.edu.cn> MIME-Version: 1.0 In-Reply-To: <20250617141416.950239-5-502024330056@smail.nju.edu.cn> X-GND-State: clean X-GND-Score: -85 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddvgdduieelkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdludehmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcupfhivgguvghrmhgrhigvrhcuoehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgeqnecuggftrfgrthhtvghrnhepieegkedtjeduffejhfetgeejtdegteetgfegtdfhjefgvefhteegkeejtddvhfevnecukfhppeeguddrieeirdeijedruddufeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeguddrieeirdeijedruddufedphhgvlhhopehlohgtrghlhhhoshhtpdhmrghilhhfrhhomhepmhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtpdhnsggprhgtphhtthhopedupdhrtghpthhtohepfhhfmhhpvghgqdguvghvvghlsehffhhmphgvghdrohhrgh X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 4/4] 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="===============8762617778654947688==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============8762617778654947688== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="OeNVgyEj0dansXkW" Content-Disposition: inline --OeNVgyEj0dansXkW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 17, 2025 at 10:14:16PM +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 two loops to free > contexts[i]->url before av_free(context). >=20 > Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> > --- > libavformat/sapenc.c | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c > index 87a834a8d8..3ba7f16022 100644 > --- a/libavformat/sapenc.c > +++ b/libavformat/sapenc.c > @@ -233,6 +233,9 @@ static int sap_write_header(AVFormatContext *s) > ret =3D AVERROR_INVALIDDATA; > goto fail; > } > + for (i =3D 0; i < s->nb_streams; i++) > + if (contexts[i]) > + av_free(contexts[i]->url); > av_freep(&contexts); > av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", &sap->ann[pos]); > pos +=3D strlen(&sap->ann[pos]); > @@ -247,6 +250,9 @@ static int sap_write_header(AVFormatContext *s) > return 0; > =20 > fail: > + for (i =3D 0; i < s->nb_streams; i++) > + if (contexts[i]) > + av_free(contexts[i]->url); > av_free(contexts); > sap_write_close(s); > return ret; this can be factored like: like + ret =3D 0; fail: + for (i =3D 0; i < s->nb_streams; i++) + if (contexts[i]) + av_free(contexts[i]->url); av_free(contexts); + if (ret < 0) sap_write_close(s); [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Some people wanted to paint the bikeshed green, some blue and some pink. People argued and fought, when they finally agreed, only rust was left. --OeNVgyEj0dansXkW Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCaFlD6wAKCRBhHseHBAsP q3weAJoDCECxr+hx4aVWk4rIxs9tbSsKEACgi+fg9atVJmrXaKbDte1LlI/oO8w= =jn0E -----END PGP SIGNATURE----- --OeNVgyEj0dansXkW-- --===============8762617778654947688== 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". --===============8762617778654947688==--