From: Markus Trippelsdorf <markus@trippelsdorf.de>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Jason Merrill <jason@redhat.com>,
gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: [PATCH] Fix UB in hash-map.h
Date: Sun, 26 Nov 2017 10:14:00 -0000 [thread overview]
Message-ID: <20171126090520.GA367@x4> (raw)
In-Reply-To: <20171125194217.GA367@x4>
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.
bootstrap-ubsan on X86_64 and ppc64le. Tested on ppc64le.
OK for trunk?
gcc/
* hash-map.h (gt_cleare_cache): Avoid UB.
diff --git a/gcc/hash-map.h b/gcc/hash-map.h
index 6b8365a9d0a6..e5630338491a 100644
--- a/gcc/hash-map.h
+++ b/gcc/hash-map.h
@@ -274,6 +274,8 @@ template<typename K, typename V, typename H>
static inline void
gt_cleare_cache (hash_map<K, V, H> *h)
{
+ if (!h)
+ return;
gt_cleare_cache (&h->m_table);
}
--
Markus
next prev parent reply other threads:[~2017-11-26 9:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 21:45 RFA (hash-map): PATCH to support GTY((cache)) with hash_map Jason Merrill
2017-11-14 12:55 ` Richard Biener
2017-11-26 0:23 ` Markus Trippelsdorf
2017-11-26 10:14 ` Markus Trippelsdorf [this message]
2017-11-27 13:01 ` [PATCH] Fix UB in hash-map.h Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171126090520.GA367@x4 \
--to=markus@trippelsdorf.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).