From 5c9d10ad9484c26eb94d2030628b676f8d0d5fc7 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Tue, 25 Oct 2011 11:15:14 -0400 Subject: Bug fix in replace(). http://code.google.com/p/arduino/issues/detail?id=694 --- cores/arduino/WString.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cores/arduino') 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; -- cgit v1.2.3-18-g5258