From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.smtpout.orange.fr (smtp-18.smtpout.orange.fr [80.12.242.18]) by sourceware.org (Postfix) with ESMTPS id 815513858C74 for ; Wed, 30 Aug 2023 08:30:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 815513858C74 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=orange.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=orange.fr Received: from [192.168.1.15] ([86.215.161.51]) by smtp.orange.fr with ESMTPA id bGapqmAIbkHhabGatqlP5p; Wed, 30 Aug 2023 10:30:32 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1693384232; bh=U9LW3t7GnvGGogpQwzYk4l/xSvvMuwc2li+jElIbaBk=; h=Date:Subject:To:References:From:In-Reply-To; b=UWU665jwmcInxZNGgKZBkCObiYVIt2Xc4jGiOSD1h4sJLxPEylM7N4NDjmr0AHsiT Ux0aR02tSNhrrmrcwMacyvXwe/TFWIXBSU8B4y3pQaBGt8joZOg1MLwK1mG3nzMV2o GprLSGHWrqz0TRHg5GLoJa7G/NSDfPs1oO0qqqmHKgsnF59/gXBMKpgBn5VD7NIegU 7cSXPoxLGH84fFBdIife0Aw+8v00Asy5Bz5JP3meyATs6b6ymUsJ+DTmf/YmrXlMmz xtmdoqxXdQ2t18GahpNv2oZuSMglxmeaf4eU+RkUR1NQ/5hcqeExvuosl4WjqQkxvR GcAqdjj/uZxvw== X-ME-Helo: [192.168.1.15] X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Wed, 30 Aug 2023 10:30:32 +0200 X-ME-IP: 86.215.161.51 Message-ID: <1b82b126-e037-4a96-a9a3-23f66686a1cf@orange.fr> Date: Wed, 30 Aug 2023 10:30:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] fortran: Restore interface to its previous state on error [PR48776] To: Harald Anlauf , Mikael Morin , fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org References: <20230827192246.2514665-1-mikael@gcc.gnu.org> Content-Language: en-US From: Mikael Morin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Le 28/08/2023 à 21:17, Harald Anlauf via Fortran a écrit : > Hi Mikael, > > On 8/27/23 21:22, Mikael Morin via Gcc-patches wrote: >> Hello, >> >> this fixes an old error-recovery bug. >> Tested on x86_64-pc-linux-gnu. >> >> OK for master? > > I have only a minor comment: > >> +/* Free the leading members of the gfc_interface linked list given in >> INTR >> +   up to the END element (exclusive: the END element is not freed). >> +   If END is not nullptr, it is assumed that END is in the linked >> list starting >> +   with INTR.  */ >> + >> +static void >> +free_interface_elements_until (gfc_interface *intr, gfc_interface *end) >> +{ >> +  gfc_interface *next; >> + >> +  for (; intr != end; intr = next) > > Would it make sense to add a protection for intr == NULL, i.e.: > > +  for (; intr && intr != end; intr = next) > > Just to prevent a NULL pointer dereference in case there > is a corruption of the chain or something else went wrong. > This would happen in the case END is not a member of the INTR linked list. In that case, the most forgiving would be not freeing any memory and just returning. But it would require walking the list a second time to determine before proceeding if END is present, and let's not do work that is expected to be useless. I will just do the change as you suggest it. > Otherwise it looks good to me. > > It appears that your patch similarly fixes PR107923.  :-) > Good news. :-) I will double check that none of the testcases there remain unfixed and close as duplicate. I don't know how you manage to make your way through the hundreds of open PRs by the way. Thanks for the review. > Thanks for the patch! > > Harald > >