From 8cb7179d24d1c560dd47c68235f7de091958a553 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 24 Jan 2017 12:00:47 +0000 Subject: [PATCH] PR libstdc++/79206 check string_view sizes in operator== PR libstdc++/79206 * include/experimental/string_view (operator==): Check sizes first. * include/std/string_view (operator==): Likewise. From-SVN: r244865 --- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/include/experimental/string_view | 6 +++--- libstdc++-v3/include/std/string_view | 6 +++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c89020ef029..24fc5ae6486 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2017-01-24 Jonathan Wakely + + PR libstdc++/79206 + * include/experimental/string_view (operator==): Check sizes first. + * include/std/string_view (operator==): Likewise. + 2017-01-23 Jonathan Wakely * testsuite/experimental/array/make_array.cc: Restore diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view index eaff0cc764c..2a2364cfa1e 100644 --- a/libstdc++-v3/include/experimental/string_view +++ b/libstdc++-v3/include/experimental/string_view @@ -456,19 +456,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline bool operator==(basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool operator==(basic_string_view<_CharT, _Traits> __x, __detail::__idt> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool operator==(__detail::__idt> __x, basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index 9eee528102c..a71918553bb 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -453,19 +453,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline bool operator==(basic_string_view<_CharT, _Traits> __x, basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool operator==(basic_string_view<_CharT, _Traits> __x, __detail::__idt> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool operator==(__detail::__idt> __x, basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) == 0; } + { return __x.size() == __y.size() && __x.compare(__y) == 0; } template inline bool -- 2.30.2