Skip to content

Commit

Permalink
Fix overlapping memcpy call in String::trim (#4938)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
earlephilhower authored Jul 19, 2018
1 parent e5648f3 commit 63ab79e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cores/esp8266/WString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ void String::trim(void) {
end--;
len = end + 1 - begin;
if(begin > buffer)
memcpy(buffer, begin, len);
memmove(buffer, begin, len);
buffer[len] = 0;
}

Expand Down

0 comments on commit 63ab79e

Please sign in to comment.