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 4675646CED for ; Mon, 14 Jul 2025 22:44:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id DFDE668F0E4; Tue, 15 Jul 2025 01:44:45 +0300 (EEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id AF85268F0A9 for ; Tue, 15 Jul 2025 01:44:39 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 17B8F1FD32 for ; Mon, 14 Jul 2025 22:44:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1752533079; 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=Ay+ljyTppno52dDAgpun2uVq9Cz23roLRuJhXJufapI=; b=kvaYiSDD59UEYUMQpMZu2Yy3OoLHTESaCfozlgqB8OE45o756U9NXRYVGKpo0gYWMhlm25 /N13J9q+sTB0FTNqxV5fGZl+KEAYqjcXTckGVgkLKs57ut4xahafKGsdxSjNECzf9+EmnU LBN8PAJhQIhdIgQpS+bx9/PH8N5LiF+2AnYTt+FIyLVFEj5CxzeBSbc21n54KsBtAl4nTK S7ivBTp+uuYQAwUZVWAUdKfI/mYL8VIAn7CcypvF81oAHsyasbUgIUOcX+l8B7+JKJw6rK jBaJlYD+drJCeSUWbiDF05kUV802IspsxkBVa18jdOze5S32vBurlZ/4tOVCPg== Date: Tue, 15 Jul 2025 00:44:37 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20250714224437.GT29660@pb2> References: <20250710194149.27218-1-jiashengjiangcool@gmail.com> <20250712134628.23368-1-jiashengjiangcool@gmail.com> MIME-Version: 1.0 In-Reply-To: <20250712134628.23368-1-jiashengjiangcool@gmail.com> X-GND-State: clean X-GND-Score: -85 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdehfedukecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdludehmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcupfhivgguvghrmhgrhigvrhcuoehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgeqnecuggftrfgrthhtvghrnhepieegkedtjeduffejhfetgeejtdegteetgfegtdfhjefgvefhteegkeejtddvhfevnecukfhppeeguddrieeirdeihedrudejieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeguddrieeirdeihedrudejiedphhgvlhhopehlohgtrghlhhhoshhtpdhmrghilhhfrhhomhepmhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtpdhnsggprhgtphhtthhopedupdhrtghpthhtohepfhhfmhhpvghgqdguvghvvghlsehffhhmphgvghdrohhrgh X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH v2] fftools/cmdutils: Add av_freep() to avoid memory leak 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="===============7358801766367611879==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============7358801766367611879== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3eoTqcGZ85bHHzcf" Content-Disposition: inline --3eoTqcGZ85bHHzcf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jul 12, 2025 at 01:46:28PM +0000, Jiasheng Jiang wrote: > Add av_freep() to free new_elem to avoid memory leak. >=20 > Fixes: 2d0bfbd0fa ("fftools/cmdutils: Use av_dynarray_add_nofree()") > Signed-off-by: Jiasheng Jiang > --- > Changlog: >=20 > v1 -> v2: >=20 > 1. Remove the unnecessary return NULL. > --- > fftools/cmdutils.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) >=20 > diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c > index e442935cae..dc093b0bd3 100644 > --- a/fftools/cmdutils.c > +++ b/fftools/cmdutils.c > @@ -1471,9 +1471,12 @@ void *allocate_array_elem(void *ptr, size_t elem_s= ize, int *nb_elems) > { > void *new_elem; > =20 > - if (!(new_elem =3D av_mallocz(elem_size)) || > - av_dynarray_add_nofree(ptr, nb_elems, new_elem) < 0) > + new_elem =3D av_mallocz(elem_size); > + if (!new_elem) > return NULL; > + if (av_dynarray_add_nofree(ptr, nb_elems, new_elem) < 0) > + av_freep(&new_elem); > + > return new_elem; > } 2d0bfbd0fa has not introduced this leak The code before exited, liek the code after but did leak too - new_elem =3D av_mallocz(elem_size); - if (!new_elem) - exit_program(1); [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Never trust a computer, one day, it may think you are the virus. -- Compn --3eoTqcGZ85bHHzcf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCaHWIUgAKCRBhHseHBAsP q/sDAJ9oA/nFhUOupVpdcmh5fr/qwf5BgwCfZB9PCbXu35zgwAl8us8jT05UXgw= =ejJ1 -----END PGP SIGNATURE----- --3eoTqcGZ85bHHzcf-- --===============7358801766367611879== 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". --===============7358801766367611879==--