btf: check hash maps are non-null before emptying

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.
This commit is contained in:
David Faust 2024-11-07 09:19:51 -08:00
parent 2a2e678407
commit 6571e8f863

View File

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