From 04f915037850166c05c73baf3d6e2ba10c790ea1 Mon Sep 17 00:00:00 2001 From: Markus Trippelsdorf Date: Mon, 27 Nov 2017 12:53:16 +0000 Subject: [PATCH] Fix UB in hash-map.h bootstrap-ubsan shows: gcc/hash-map.h:277:19: runtime error: member access within null pointer of type 'struct hash_map' Fix the issue by returning early. From-SVN: r255166 --- gcc/ChangeLog | 4 ++++ gcc/hash-map.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a7066fb7ad1..98e49cdb9c0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2017-11-27 Markus Trippelsdorf + + * hash-map.h (gt_cleare_cache): Avoid UB. + 2017-11-27 Eric Botcazou * cfgloop.h (struct loop): Document usage of USHRT_MAX for unroll. diff --git a/gcc/hash-map.h b/gcc/hash-map.h index 6b8365a9d0a..10ae52d194a 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -274,7 +274,8 @@ template static inline void gt_cleare_cache (hash_map *h) { - gt_cleare_cache (&h->m_table); + if (h) + gt_cleare_cache (&h->m_table); } template -- 2.30.2