Fix replace() failing (#6224)

This commit is contained in:
s-hadinger 2022-02-03 19:07:34 +01:00 committed by GitHub
parent 0ea485e518
commit 6591f5bd4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -774,9 +774,10 @@ void String::replace(const String& find, const String& replace) {
}
if(size == len())
return;
if(size > capacity() && !changeBuffer(size))
if(size > capacity() && !changeBuffer(size)) {
log_w("String.Replace() Insufficient space to replace string");
return;
}
int index = len() - 1;
while(index >= 0 && (index = lastIndexOf(find, index)) >= 0) {
readFrom = wbuffer() + index + find.len();