Skip to content

Commit d7623fc

Browse files
Fix WString optimization
PR esp8266#6573 introduced a corner case where a blind String() without any initialization was in an in invalid state because the buffer and len would not be updated properly. Concatenating to the empty string could cause a failure. Now, set the default state in ::init() to SSO (which is what happened before when we were using String(char *s="")) and fix the crash.
1 parent 4890aaf commit d7623fc

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

cores/esp8266/WString.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,8 @@ String::~String() {
129129
// /*********************************************/
130130

131131
inline void String::init(void) {
132-
setSSO(false);
133-
setCapacity(0);
132+
setSSO(true);
134133
setLen(0);
135-
setBuffer(nullptr);
136134
}
137135

138136
void String::invalidate(void) {

0 commit comments

Comments
 (0)