1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

Fix String.replace overlapping strcpy (#5966)

* Fix String.replace overlapping strcpy

Fixes #5949

Adds a test from the issue above and fixes the problem valgrind found.

Additional pathological memcpy->memmove fixes
This commit is contained in:
Earle F. Philhower, III
2019-04-10 17:21:15 +03:00
committed by GitHub
parent 4b596d8fb1
commit 9712170276
2 changed files with 18 additions and 6 deletions

View File

@ -428,3 +428,15 @@ TEST_CASE("String SSO handles junk in memory", "[core][String]")
REQUIRE(*s == "CO2_defect");
s->~String();
}
TEST_CASE("Issue #5949 - Overlapping src/dest in replace", "[core][String]")
{
String blah = "blah";
blah.replace("xx", "y");
REQUIRE(blah == "blah");
blah.replace("x", "yy");
REQUIRE(blah == "blah");
blah.replace(blah, blah);
REQUIRE(blah == "blah");
}