Skip to content

Commit

Permalink
Bug fix in replace().
Browse files Browse the repository at this point in the history
  • Loading branch information
damellis committed Oct 25, 2011
1 parent e1dbe68 commit d9f9676
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hardware/arduino/cores/arduino/WString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ void String::replace(const String& find, const String& replace)
if (size == len) return;
if (size > capacity && !changeBuffer(size)) return; // XXX: tell user!
int index = len - 1;
while ((index = lastIndexOf(find, index)) >= 0) {
while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) {
readFrom = buffer + index + find.len;
memmove(readFrom + diff, readFrom, len - (readFrom - buffer));
len += diff;
Expand Down

0 comments on commit d9f9676

Please sign in to comment.