Basic Infos
Problem Description
See line 291 (and line 280):
|
String &String::copy(const __FlashStringHelper *pstr, unsigned int length) { |
|
if (!reserve(length)) { |
|
invalidate(); |
|
return *this; |
|
} |
|
setLen(length); |
|
memcpy_P(wbuffer(), (PGM_P)pstr, length); // We know wbuffer() cannot ever be in PROGMEM, so memcpy safe here |
|
wbuffer()[length] = 0; |
|
return *this; |
|
} |
When allocating an array of N elements, accessing element [N] is out of bounds.
This only happens sometimes at very specific string lengths, as setLen only allocates in multiples of N bytes.
N.B. similar issue for ESP32, so I will also add an issue there.
Suggested fix:
N.B. This function is likely to be called with strlen() or strlen_P() as argument, which does not include the ending null character.
Basic Infos
Problem Description
See line 291 (and line 280):
Arduino/cores/esp8266/WString.cpp
Lines 284 to 293 in eda4e08
When allocating an array of N elements, accessing element
[N]is out of bounds.This only happens sometimes at very specific string lengths, as
setLenonly allocates in multiples of N bytes.N.B. similar issue for ESP32, so I will also add an issue there.
Suggested fix:
N.B. This function is likely to be called with
strlen()orstrlen_P()as argument, which does not include the ending null character.