Skip to content

Commit 4e93584

Browse files
d-a-vearlephilhower
authored andcommitted
wstring: fix concatenation from flash (#6368)
fixes #6367
1 parent f78ab66 commit 4e93584

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: cores/esp8266/WString.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,12 @@ unsigned char String::concat(const char *cstr, unsigned int length) {
330330
return 1;
331331
if(!reserve(newlen))
332332
return 0;
333-
memmove(wbuffer() + len(), cstr, length + 1);
333+
if (cstr >= wbuffer() && cstr < wbuffer() + len())
334+
// compatible with SSO in ram #6155 (case "x += x.c_str()")
335+
memmove(wbuffer() + len(), cstr, length + 1);
336+
else
337+
// compatible with source in flash #6367
338+
memcpy_P(wbuffer() + len(), cstr, length + 1);
334339
setLen(newlen);
335340
return 1;
336341
}

0 commit comments

Comments
 (0)