Skip to content

Commit

Permalink
sstring: fix bounds checks in find()
Browse files Browse the repository at this point in the history
'end' iterator was set past the end if pos != 0.
  • Loading branch information
tgrabiec authored and avikivity committed Mar 17, 2015
1 parent ceb4778 commit a7d6e22
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/sstring.hh
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public:

size_t find(char_type t, size_t pos = 0) const noexcept {
const char_type* it = str() + pos;
const char_type* end = it + size();
const char_type* end = str() + size();
while (it < end) {
if (*it == t) {
return it - str();
Expand All @@ -190,7 +190,7 @@ public:

size_t find(const basic_sstring& s, size_t pos = 0) const noexcept {
const char_type* it = str() + pos;
const char_type* end = it + size();
const char_type* end = str() + size();
const char_type* c_str = s.str();
const char_type* c_str_end = s.str() + s.size();

Expand Down

0 comments on commit a7d6e22

Please sign in to comment.