]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
btf: check hash maps are non-null before emptying
authorDavid Faust <david.faust@oracle.com>
Thu, 7 Nov 2024 17:19:51 +0000 (09:19 -0800)
committerDavid Faust <david.faust@oracle.com>
Thu, 7 Nov 2024 17:57:25 +0000 (09:57 -0800)
These maps will always be non-null in btf_finalize under normal
circumstances, but be safe and verify that before trying to empty them.

gcc/
* btfout.cc (btf_finalize): Check that hash maps are non-null before
emptying them.

gcc/btfout.cc

index 083ca48d6279ab82a9c26508c3d32c73114b05cf..4a6b5453e08e211bc3112b3659387bf511c497c7 100644 (file)
@@ -1661,13 +1661,19 @@ btf_finalize (void)
   datasecs.release ();
 
   funcs = NULL;
-  func_map->empty ();
-  func_map = NULL;
+  if (func_map)
+    {
+      func_map->empty ();
+      func_map = NULL;
+    }
 
   if (debug_prune_btf)
     {
-      btf_used_types->empty ();
-      btf_used_types = NULL;
+      if (btf_used_types)
+       {
+         btf_used_types->empty ();
+         btf_used_types = NULL;
+       }
 
       fixups.release ();
       forwards = NULL;