fix(esp32): Fix appending to Strings longer than 64k (#11523)
If oldLen is truncated to uint16_t, appending to a String that is longer than 65535 bytes will create a broken string.
This commit is contained in:
parent
6754b1962c
commit
6476260e8f
1 changed files with 3 additions and 3 deletions
|
|
@ -180,7 +180,7 @@ bool String::changeBuffer(unsigned int maxStrLen) {
|
|||
if (maxStrLen < sizeof(sso.buff) - 1) {
|
||||
if (isSSO() || !buffer()) {
|
||||
// Already using SSO, nothing to do
|
||||
uint16_t oldLen = len();
|
||||
size_t oldLen = len();
|
||||
setSSO(true);
|
||||
setLen(oldLen);
|
||||
} else { // if bufptr && !isSSO()
|
||||
|
|
@ -188,7 +188,7 @@ bool String::changeBuffer(unsigned int maxStrLen) {
|
|||
char temp[sizeof(sso.buff)];
|
||||
memcpy(temp, buffer(), maxStrLen);
|
||||
free(wbuffer());
|
||||
uint16_t oldLen = len();
|
||||
size_t oldLen = len();
|
||||
setSSO(true);
|
||||
memcpy(wbuffer(), temp, maxStrLen);
|
||||
setLen(oldLen);
|
||||
|
|
@ -201,7 +201,7 @@ bool String::changeBuffer(unsigned int maxStrLen) {
|
|||
if (newSize > CAPACITY_MAX) {
|
||||
return false;
|
||||
}
|
||||
uint16_t oldLen = len();
|
||||
size_t oldLen = len();
|
||||
char *newbuffer = (char *)realloc(isSSO() ? nullptr : wbuffer(), newSize);
|
||||
if (newbuffer) {
|
||||
size_t oldSize = capacity() + 1; // include NULL.
|
||||
|
|
|
|||
Loading…
Reference in a new issue