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



Reply via email to