Bug fix in replace().

http://code.google.com/p/arduino/issues/detail?id=694
This commit is contained in:
David A. Mellis 2011-10-25 11:15:14 -04:00
parent 8d48010edf
commit 5c9d10ad94
1 changed files with 1 additions and 1 deletions

View File

@ -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;