aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
authorDavid A. Mellis <d.mellis@arduino.cc>2011-10-25 11:15:14 -0400
committerDavid A. Mellis <d.mellis@arduino.cc>2011-10-25 11:15:14 -0400
commit5c9d10ad9484c26eb94d2030628b676f8d0d5fc7 (patch)
tree66c7fd310463e7381c216aa48be5533d786be203 /cores/arduino
parent8d48010edfd3a031045bc510c7bcd651cf30c6f8 (diff)
Bug fix in replace().
http://code.google.com/p/arduino/issues/detail?id=694
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/WString.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp
index ad8d828..3e81331 100644
--- a/cores/arduino/WString.cpp
+++ b/cores/arduino/WString.cpp
@@ -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;