Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6476260

Browse files
fix(esp32): Fix appending to Strings longer than 64k (espressif#11523)
If oldLen is truncated to uint16_t, appending to a String that is longer than 65535 bytes will create a broken string.
1 parent 6754b19 commit 6476260

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎cores/esp32/WString.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ bool String::changeBuffer(unsigned int maxStrLen) {
180180
if (maxStrLen < sizeof(sso.buff) - 1) {
181181
if (isSSO() || !buffer()) {
182182
// Already using SSO, nothing to do
183-
uint16_t oldLen = len();
183+
size_t oldLen = len();
184184
setSSO(true);
185185
setLen(oldLen);
186186
} else { // if bufptr && !isSSO()
187187
// Using bufptr, need to shrink into sso.buff
188188
char temp[sizeof(sso.buff)];
189189
memcpy(temp, buffer(), maxStrLen);
190190
free(wbuffer());
191-
uint16_t oldLen = len();
191+
size_t oldLen = len();
192192
setSSO(true);
193193
memcpy(wbuffer(), temp, maxStrLen);
194194
setLen(oldLen);
@@ -201,7 +201,7 @@ bool String::changeBuffer(unsigned int maxStrLen) {
201201
if (newSize > CAPACITY_MAX) {
202202
return false;
203203
}
204-
uint16_t oldLen = len();
204+
size_t oldLen = len();
205205
char *newbuffer = (char *)realloc(isSSO() ? nullptr : wbuffer(), newSize);
206206
if (newbuffer) {
207207
size_t oldSize = capacity() + 1; // include NULL.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /