[2/2] Clean next_nested properly.
diff mbox series

Message ID 2e51950cd70703be3d9aa65487b94f742f7b7e88.1565783608.git.mliska@suse.cz
State New
Headers show
Series
  • Fix dangling pointer in next_nested.
Related show

Commit Message

Martin Liška Aug. 14, 2019, 11:17 a.m. UTC
gcc/ChangeLog:

2019-08-14  Martin Liska  <mliska@suse.cz>

	PR ipa/91438
	* cgraph.c (cgraph_node::remove): When setting
	n->origin = NULL for all nested functions, reset
	also next_nested.
---
 gcc/cgraph.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Jeff Law Aug. 14, 2019, 5:05 p.m. UTC | #1
On 8/14/19 5:17 AM, Martin Liska wrote:
> 
> gcc/ChangeLog:
> 
> 2019-08-14  Martin Liska  <mliska@suse.cz>
> 
> 	PR ipa/91438
> 	* cgraph.c (cgraph_node::remove): When setting
> 	n->origin = NULL for all nested functions, reset
> 	also next_nested.
> ---
>  gcc/cgraph.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
OK
jeff

Patch
diff mbox series

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index eb38b905879..ea8ab38d806 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1767,8 +1767,6 @@  cgraph_node::release_body (bool keep_arguments)
 void
 cgraph_node::remove (void)
 {
-  cgraph_node *n;
-
   if (symtab->ipa_clones_dump_file && symtab->cloned_nodes.contains (this))
     fprintf (symtab->ipa_clones_dump_file,
 	     "Callgraph removal;%s;%d;%s;%d;%d\n", asm_name (), order,
@@ -1785,8 +1783,13 @@  cgraph_node::remove (void)
      */
   force_output = false;
   forced_by_abi = false;
-  for (n = nested; n; n = n->next_nested)
+  cgraph_node *next = nested;
+  for (cgraph_node *n = nested; n; n = next)
+  {
+    next = n->next_nested;
     n->origin = NULL;
+    n->next_nested = NULL;
+  }
   nested = NULL;
   if (origin)
     {
@@ -1840,7 +1843,7 @@  cgraph_node::remove (void)
      */
   if (symtab->state != LTO_STREAMING)
     {
-      n = cgraph_node::get (decl);
+      cgraph_node *n = cgraph_node::get (decl);
       if (!n
 	  || (!n->clones && !n->clone_of && !n->global.inlined_to
 	      && ((symtab->global_info_ready || in_lto_p)