8000 Fix overlapping memcpy call in String::trim (#4938) · simap/Arduino@63ab79e · GitHub
[go: up one dir, main page]

Skip to content

Commit 63ab79e

Browse files
Fix overlapping memcpy call in String::trim (esp8266#4938)
memcpy() is undefined when source and destination overlap. String::trim uses it when shifting the string left to remove left padding. Replace with memmove() which is always safe, even when overlapped.
1 parent e5648f3 commit 63ab79e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cores/esp8266/WString.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ void String::trim(void) {
753753
end--;
754754
len = end + 1 - begin;
755755
if(begin > buffer)
756-< 4D6C /span>
memcpy(buffer, begin, len);
756+
memmove(buffer, begin, len);
757757
buffer[len] = 0;
758758
}
759759

0 commit comments

Comments
 (0)
0