diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-11-01 15:21:17 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-11-01 15:21:17 +0000 |
commit | f30015e2151e54d5672344406f11f1053fc9ef70 (patch) | |
tree | e9db3d9ecc9aed3287139b8ed768e611f1fedca1 /libstdc++-v3 | |
parent | 50368af82ca24f40c06f03b5b496525a8e4ce20d (diff) | |
download | ppe42-gcc-f30015e2151e54d5672344406f11f1053fc9ef70.tar.gz ppe42-gcc-f30015e2151e54d5672344406f11f1053fc9ef70.zip |
2002-11-01 John Carter <john.carter@tait.co.nz>
PR libstdc++/7961
* include/bits/basic_string.tcc
(compare(const _CharT* __s)): Don't access __s past its length.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@58717 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_string.tcc | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 3a2ee83669c..734aa7f11ef 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2002-11-01 John Carter <john.carter@tait.co.nz> + + PR libstdc++/7961 + * include/bits/basic_string.tcc + (compare(const _CharT* __s)): Don't access __s past its length. + 2002-10-31 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/8348 diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 3047dfa5ba7..198f190eae8 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -884,9 +884,11 @@ namespace std compare(const _CharT* __s) const { size_type __size = this->size(); - int __r = traits_type::compare(_M_data(), __s, __size); + size_type __osize = traits_type::length(__s); + size_type __len = min(__size, __osize); + int __r = traits_type::compare(_M_data(), __s, __len); if (!__r) - __r = __size - traits_type::length(__s); + __r = __size - __osize; return __r; } |