mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-22 08:22:04 +03:00
Fix overlapping memcpy call in String::trim (#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.
This commit is contained in:
committed by
GitHub
parent
e5648f3dfd
commit
63ab79e549
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user