]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
basic_string.tcc (find(const _CharT*, size_type, size_type)): Robustify.
authorPaolo Carlini <pcarlini@suse.de>
Tue, 5 Sep 2006 17:38:44 +0000 (17:38 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 5 Sep 2006 17:38:44 +0000 (17:38 +0000)
2006-09-05  Paolo Carlini  <pcarlini@suse.de>

* include/bits/basic_string.tcc (find(const _CharT*, size_type,
size_type)): Robustify.
* include/ext/vstring.tcc (find(const _CharT*, size_type,
size_type)): Likewise.

From-SVN: r116700

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/basic_string.tcc
libstdc++-v3/include/ext/vstring.tcc

index 6397850f3c04df458083b9a92a17719840b8fe2c..5250cccdcf09cad7e424a37ad8478123f3c51427 100644 (file)
@@ -1,3 +1,10 @@
+2006-09-05  Paolo Carlini  <pcarlini@suse.de>
+
+       * include/bits/basic_string.tcc (find(const _CharT*, size_type,
+       size_type)): Robustify.
+       * include/ext/vstring.tcc (find(const _CharT*, size_type,
+       size_type)): Likewise.
+
 2006-09-05  Paolo Carlini  <pcarlini@suse.de>
 
        * include/bits/basic_string.tcc (find(const _CharT*, size_type,
index 048d0cedc5ac677ed9111878180d9f9489fea2cf..4cf5f29ad36dbb47ff940081e29fefcc72a31290 100644 (file)
@@ -716,10 +716,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       if (__n == 0)
        return __pos <= __size ? __pos : npos;
 
-      for (; __pos + __n <= __size; ++__pos)
-       if (traits_type::eq(__data[__pos], __s[0])
-           && traits_type::compare(__data + __pos + 1, __s + 1, __n - 1) == 0)
-         return __pos;
+      if (__n <= __size)
+       {
+         for (; __pos + __n <= __size; ++__pos)
+           if (traits_type::eq(__data[__pos], __s[0])
+               && traits_type::compare(__data + __pos + 1,
+                                       __s + 1, __n - 1) == 0)
+             return __pos;
+       }
       return npos;
     }
 
index 5196d10c6d9cedbfb46a40d11aac25b4df00618f..2a880d99734c7e0b2488e32f7385d9191cff49d3 100644 (file)
@@ -277,10 +277,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
       if (__n == 0)
        return __pos <= __size ? __pos : npos;
 
-      for (; __pos + __n <= __size; ++__pos)
-       if (traits_type::eq(__data[__pos], __s[0])
-           && traits_type::compare(__data + __pos + 1, __s + 1, __n - 1) == 0)
-         return __pos;
+      if (__n <= __size)
+       {
+         for (; __pos + __n <= __size; ++__pos)
+           if (traits_type::eq(__data[__pos], __s[0])
+               && traits_type::compare(__data + __pos + 1,
+                                       __s + 1, __n - 1) == 0)
+             return __pos;
+       }
       return npos;
     }