Skip to content

Commit d9f9676

Browse files
committed
1 parent e1dbe68 commit d9f9676

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hardware/arduino/cores/arduino/WString.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ void String::replace(const String& find, const String& replace)
593593
if (size == len) return;
594594
if (size > capacity && !changeBuffer(size)) return; // XXX: tell user!
595595
int index = len - 1;
596-
while ((index = lastIndexOf(find, index)) >= 0) {
596+
while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) {
597597
readFrom = buffer + index + find.len;
598598
memmove(readFrom + diff, readFrom, len - (readFrom - buffer));
599599
len += diff;

0 commit comments

Comments
 (0)