public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] PR libstdc++/89446 fix null pointer dereference in char_traits
Date: Sat, 23 Feb 2019 01:27:00 -0000	[thread overview]
Message-ID: <20190223010611.GN7611@tucnak> (raw)
In-Reply-To: <20190223010220.GA32714@redhat.com>

On Sat, Feb 23, 2019 at 01:02:20AM +0000, Jonathan Wakely wrote:
> 	PR libstdc++/89446
> 	* include/bits/char_traits.h (__constant_char_array): Check index is
> 	in range before dereferencing.
> 	* testsuite/21_strings/basic_string_view/operators/char/89446.cc:
> 	New test.
> 
> Tested x86_64-linux, committed to gcc-8-branch and gcc-7-branch.

And not trunk?  The bug is still there, even when it should be usually
ifdefed out because __builtin_is_constexpr_evaluated() should be supported.

> commit b639a9cac6e2532eb852b03df6ac40d34f1dd28c
> Author: Jonathan Wakely <jwakely@redhat.com>
> Date:   Fri Feb 22 20:33:16 2019 +0000
> 
>     PR libstdc++/89446 fix null pointer dereference in char_traits
>     
>             PR libstdc++/89446
>             * include/bits/char_traits.h (__constant_char_array): Check index is
>             in range before dereferencing.
>             * testsuite/21_strings/basic_string_view/operators/char/89446.cc:
>             New test.
> 
> diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h
> index 1945494d7e2..a2a883f3565 100644
> --- a/libstdc++-v3/include/bits/char_traits.h
> +++ b/libstdc++-v3/include/bits/char_traits.h
> @@ -248,7 +248,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>      __constant_char_array_p(const _CharT* __a, size_t __n)
>      {
>        size_t __i = 0;
> -      while (__builtin_constant_p(__a[__i]) && __i < __n)
> +      while (__i < __n && __builtin_constant_p(__a[__i]))
>  	__i++;
>        return __i == __n;
>      }

	Jakub

  reply	other threads:[~2019-02-23  1:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-23  1:11 Jonathan Wakely
2019-02-23  1:27 ` Jakub Jelinek [this message]
2019-02-23  2:04   ` Jonathan Wakely
2019-02-23  7:17     ` Jonathan Wakely
2019-02-23  2:26 ` Jonathan Wakely
2019-02-23 14:59   ` Eric Botcazou
2019-02-24 12:02     ` Jonathan Wakely

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=20190223010611.GN7611@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    /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).