[1/2] Add ::verify for cgraph_node::origin/nested/next_nested.
diff mbox series

Message ID 78a42e1a2102e60a6dd107a090028e9d2db45d7a.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:15 a.m. UTC
gcc/ChangeLog:

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

	* cgraph.c (cgraph_node::verify_node): Verify origin, nested
	and next_nested.
---
 gcc/cgraph.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Jeff Law Aug. 14, 2019, 5:04 p.m. UTC | #1
On 8/14/19 5:15 AM, Martin Liska wrote:
> 
> gcc/ChangeLog:
> 
> 2019-08-14  Martin Liska  <mliska@suse.cz>
> 
> 	* cgraph.c (cgraph_node::verify_node): Verify origin, nested
> 	and next_nested.
> ---
>  gcc/cgraph.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
OK.
Jeff

Patch
diff mbox series

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index ed46d81a513..eb38b905879 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -3464,6 +3464,30 @@  cgraph_node::verify_node (void)
 	  e->aux = 0;
 	}
     }
+
+  if (nested != NULL)
+    {
+      for (cgraph_node *n = nested; n != NULL; n = n->next_nested)
+	{
+	  if (n->origin == NULL)
+	    {
+	      error ("missing origin for a node in a nested list");
+	      error_found = true;
+	    }
+	  else if (n->origin != this)
+	    {
+	      error ("origin points to a different parent");
+	      error_found = true;
+	      break;
+	    }
+	}
+    }
+  if (next_nested != NULL && origin == NULL)
+    {
+      error ("missing origin for a node in a nested list");
+      error_found = true;
+    }
+
   if (error_found)
     {
       dump (stderr);