public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Markus Trippelsdorf <markus@trippelsdorf.de>
Cc: Jason Merrill <jason@redhat.com>,
	gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix UB in hash-map.h
Date: Mon, 27 Nov 2017 13:01:00 -0000	[thread overview]
Message-ID: <CAFiYyc3bs7H9ohtuSNx5g31C+2T4YZPFvMFvFyqdLCJ5oVu29w@mail.gmail.com> (raw)
In-Reply-To: <20171126090520.GA367@x4>

On Sun, Nov 26, 2017 at 10:05 AM, Markus Trippelsdorf
<markus@trippelsdorf.de> wrote:
> 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?

Ok.

> 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

      reply	other threads:[~2017-11-27 12:45 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     ` [PATCH] Fix UB in hash-map.h Markus Trippelsdorf
2017-11-27 13:01       ` Richard Biener [this message]

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=CAFiYyc3bs7H9ohtuSNx5g31C+2T4YZPFvMFvFyqdLCJ5oVu29w@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=markus@trippelsdorf.de \
    /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).