From 454295892a0e2b6767f625c99499fa1864261a6d Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Wed, 18 Jul 2018 13:05:57 -0700 Subject: [PATCH] Fix overlapping memcpy call in String::trim 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. --- cores/esp8266/WString.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp8266/WString.cpp b/cores/esp8266/WString.cpp index c81b594d6c..7e5d1b58d8 100644 --- a/cores/esp8266/WString.cpp +++ b/cores/esp8266/WString.cpp @@ -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; }