Skip to content

Commit 6f0ba88

Browse files
committed
Don't mess with the original in String::substring
From upstream ArduinoCore-API commit dd236bfd2c62ed083aaa1b1229d71e85fd92f7a9
1 parent ecfafe3 commit 6f0ba88

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

cores/esp32/WString.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,7 @@ String String::substring(unsigned int left, unsigned int right) const {
711711
return out;
712712
if(right > len())
713713
right = len();
714-
char temp = buffer()[right]; // save the replaced character
715-
wbuffer()[right] = '\0';
716-
out = wbuffer() + left; // pointer arithmetic
717-
wbuffer()[right] = temp; //restore character
714+
out.copy(buffer() + left, right - left);
718715
return out;
719716
}
720717

0 commit comments

Comments
 (0)