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 215995037B for ; Fri, 11 Jul 2025 23:20:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id C653D6903B4; Sat, 12 Jul 2025 02:20:23 +0300 (EEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 7B35468F0BC for ; Sat, 12 Jul 2025 02:20:17 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id B122041C7B for ; Fri, 11 Jul 2025 23:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1752276016; 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=hG27ppskfykW7vXxZq996jmwxIjQAtWcCIeCLPLxvtQ=; b=fLHZM/njmoMYglGC2nLu9Zc+InUSPmKMRtC4dt3y0sfiitYDJKj0ChmMYwfonoXf4Q4l/L LWlgJzCy2DcmPmFf9G2fFvlikrycvE/KrLi7eWcIIhIHmQKafNHsH2BA9owj3TUe1QSBz3 yfmIaRI7Dl26AD6f/bjwsokg/KQO5c8Yj2JB+rCYLNGydoqZ/cgVPlIzmYvYBtVvrZ5sio LXuyO3FHzdP6LAiuOBrJ0tC8VTWN0RxEDJtWJJHe1EB/AA+5qK+xAUQEU22c0ZKhA7i3yw +gBtODZfeyHO7zOzN2fRRYo+V3ZYOJb4V0JK1S4oDtE2kLe98jDwLAYNA8NGEA== Date: Sat, 12 Jul 2025 01:20:15 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20250711232015.GW29660@pb2> References: <20250710194149.27218-1-jiashengjiangcool@gmail.com> MIME-Version: 1.0 In-Reply-To: <20250710194149.27218-1-jiashengjiangcool@gmail.com> X-GND-State: clean X-GND-Score: -85 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdeggeeivdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdludehmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcupfhivgguvghrmhgrhigvrhcuoehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgeqnecuggftrfgrthhtvghrnhepieegkedtjeduffejhfetgeejtdegteetgfegtdfhjefgvefhteegkeejtddvhfevnecukfhppeeguddrieeirdeihedrudejieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeguddrieeirdeihedrudejiedphhgvlhhopehlohgtrghlhhhoshhtpdhmrghilhhfrhhomhepmhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtpdhnsggprhgtphhtthhopedupdhrtghpthhtohepfhhfmhhpvghgqdguvghvvghlsehffhhmphgvghdrohhrgh X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH] 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="===============2764738754887489763==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============2764738754887489763== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="j/HMB0Hmuuaur/5c" Content-Disposition: inline --j/HMB0Hmuuaur/5c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 10, 2025 at 07:41:49PM +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 > --- > fftools/cmdutils.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c > index e442935cae..5c8d09f87a 100644 > --- a/fftools/cmdutils.c > +++ b/fftools/cmdutils.c > @@ -1471,9 +1471,13 @@ 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 NULL; > + } > return new_elem; teh return NULL is not needed as av_freep sets new_elem to NULL [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin --j/HMB0Hmuuaur/5c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCaHGcLAAKCRBhHseHBAsP q4tsAJ9AnGlEbsaKS3koSo+FHgohj/gfHgCfZe6i166ymZEegLYS1ZE5h3/AyNg= =gT9Z -----END PGP SIGNATURE----- --j/HMB0Hmuuaur/5c-- --===============2764738754887489763== 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". --===============2764738754887489763==--