From: David Faust Date: Thu, 7 Nov 2024 17:19:51 +0000 (-0800) Subject: btf: check hash maps are non-null before emptying X-Git-Tag: basepoints/gcc-16~4528 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6571e8f863736b7705f59c9ab0f17b7c4fdbcf92;p=thirdparty%2Fgcc.git 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. --- diff --git a/gcc/btfout.cc b/gcc/btfout.cc index 083ca48d6279..4a6b5453e08e 100644 --- a/gcc/btfout.cc +++ b/gcc/btfout.cc @@ -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;