PR libstdc++/89446 fix null pointer dereference in char_traits
authorJonathan Wakely <jwakely@redhat.com>
Sat, 23 Feb 2019 03:01:59 +0000 (03:01 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Sat, 23 Feb 2019 03:01:59 +0000 (03:01 +0000)
commitace857f95d819377507f81ff4fc88ebf8b913eef
tree9bda6298fff3246b502dd0c0e4c2db91fb0c6e96
parentc1753302087205dd9d5e9013c859623b261df060
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.
(char_traits<char>::compare, char_traits<char>::find)
(char_traits<char8_t>::compare, char_traits<char8_t>::find): Return
immediately if n is zero.
(char_traits<wchar_t>::compare, char_traits<wchar_t>::find): Likewise.
Remove workarounds for PR 67026.
* testsuite/21_strings/basic_string_view/operators/char/89446.cc:
New test.
* testsuite/21_strings/basic_string_view/operators/wchar_t/89446.cc:
New test.

From-SVN: r269148
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/char_traits.h
libstdc++-v3/testsuite/21_strings/basic_string_view/operators/char/89446.cc [new file with mode: 0644]
libstdc++-v3/testsuite/21_strings/basic_string_view/operators/wchar_t/89446.cc [new file with mode: 0644]