diff options
author | Markus Trippelsdorf <markus@trippelsdorf.de> | 2017-11-27 12:53:16 +0000 |
---|---|---|
committer | Markus Trippelsdorf <trippels@gcc.gnu.org> | 2017-11-27 12:53:16 +0000 |
commit | 04f915037850166c05c73baf3d6e2ba10c790ea1 (patch) | |
tree | 703d423fa1f611f0b40c39291c259f3f9c44229d | |
parent | ff27462edc398ca82e86c8c7f13d9fab498ba5c1 (diff) | |
download | gcc-04f915037850166c05c73baf3d6e2ba10c790ea1.zip gcc-04f915037850166c05c73baf3d6e2ba10c790ea1.tar.gz gcc-04f915037850166c05c73baf3d6e2ba10c790ea1.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/hash-map.h | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a7066fb..98e49cd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2017-11-27 Markus Trippelsdorf <markus@trippelsdorf.de> + + * hash-map.h (gt_cleare_cache): Avoid UB. + 2017-11-27 Eric Botcazou <ebotcazou@adacore.com> * cfgloop.h (struct loop): Document usage of USHRT_MAX for unroll. diff --git a/gcc/hash-map.h b/gcc/hash-map.h index 6b8365a9d..10ae52d 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -274,7 +274,8 @@ template<typename K, typename V, typename H> static inline void gt_cleare_cache (hash_map<K, V, H> *h) { - gt_cleare_cache (&h->m_table); + if (h) + gt_cleare_cache (&h->m_table); } template<typename K, typename V, typename H> |