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 11DD349278 for ; Tue, 6 Feb 2024 20:53:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 41DE368D085; Tue, 6 Feb 2024 22:53:43 +0200 (EET) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B41B168CAB8 for ; Tue, 6 Feb 2024 22:53:36 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0E25E1C0005 for ; Tue, 6 Feb 2024 20:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1707252816; 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=+BKT0uf9lU21paic9Jo5D2IARijXM6hujf1OBYvld4M=; b=MW5SQly5IIHZxghlgcZppdVgCqVztsZRmF1So4vcod+H4B18NKyT1ro3HgAX7+eCj/ETtq XULYNzm9Xyw0N02iCYA0X0O2B3mtGL8oNWS83UruZ586b4XOqzmbFmWzhciVZLh6LIF8Ak IMY2jikzCgF7nD0OWbnlbfSu+U2V/VwHelCeAKUTSKItSMEraFLhatGK1Ke7Y6LBAMUCXm plRWsKyyuoNCnpAMB9K/YCKcay5VmCs36ftNvGtMDKy6FtB0v9C0MLgT2325pHdlr23p/9 YkjCGawC0+2VV36LfiOuQPKwCR5TSPE0C2+gdLYz62pvrlswBEPVIXkzNmO5UA== Date: Tue, 6 Feb 2024 21:53:35 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240206205335.GC6420@pb2> References: <20240205114459.8317-1-michael@niedermayer.cc> <20240206004001.GV6420@pb2> MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 1/2] avfilter/signature_lookup: dont leave uncleared pointers in sll_free() 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="===============1272838620348935906==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============1272838620348935906== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="d8ClxENcQKapV8UM" Content-Disposition: inline --d8ClxENcQKapV8UM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 06, 2024 at 11:36:13AM +0100, Andreas Rheinhardt wrote: > Michael Niedermayer: > > On Mon, Feb 05, 2024 at 12:51:57PM +0100, Andreas Rheinhardt wrote: > >> Michael Niedermayer: > >>> Signed-off-by: Michael Niedermayer > >>> --- > >>> libavfilter/signature_lookup.c | 21 ++++++++++----------- > >>> 1 file changed, 10 insertions(+), 11 deletions(-) > >>> > >>> diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_l= ookup.c > >>> index 86dd0c66754..52a97e1bc7e 100644 > >>> --- a/libavfilter/signature_lookup.c > >>> +++ b/libavfilter/signature_lookup.c > >>> @@ -37,6 +37,15 @@ > >>> #define STATUS_END_REACHED 1 > >>> #define STATUS_BEGIN_REACHED 2 > >>> =20 > >>> +static void sll_free(MatchingInfo **sll) > >>> +{ > >>> + while (*sll) { > >>> + MatchingInfo *tmp =3D *sll; > >>> + *sll =3D (*sll)->next; > >>> + av_free(tmp); > >>> + } > >> > >> This does not clear the pointers at all. This does (and avoids > >> indirections). > >> > >> static void sll_free(MatchingInfo **sllp) > >> { > >> MatchingInfo *sll =3D *sllp; > >> > >> *sllp =3D NULL; > >> while (sll) { > >> MatchingInfo *tmp =3D sll; > >> sll =3D sll->next; > >> av_free(tmp); > >> } > >> } > >=20 > > I tried it with code below, but your code is not different from mine in= behavior just more complex > >=20 >=20 > Your code indeed resets the pointer; it overwrites the pointer once per > loop iteration and so sets it to NULL in the last iteration. I somehow > overlooked that. > I actually consider your code more complex (my code resets the original > pointer and directly traverses the list, your code does the same, but in > between it overwrites the original pointer to store the next pointer > instead of using a simple stack variable for this purpose). > Apply as you wish. ok [...] > sll_free_n2() is not recursive. the function is cursed, noone can implement it without bugs thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu --d8ClxENcQKapV8UM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZcKcSAAKCRBhHseHBAsP q1QQAKCb92oWuJVcKceS6NDfVSVDZT83yQCglN463QWIsGHfLh9f2R7W4FNS+zU= =Ka+k -----END PGP SIGNATURE----- --d8ClxENcQKapV8UM-- --===============1272838620348935906== 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". --===============1272838620348935906==--