Skip to content

Commit ee94c5c

Browse files
authored
Fix crash in String when using nullptr (#10971)
Fixes: #10971
1 parent a7907cd commit ee94c5c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cores/esp32/WString.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ String &String::operator=(StringSumHelper &&rval) {
290290
#endif
291291

292292
String &String::operator=(const char *cstr) {
293-
return copy(cstr, strlen(cstr));
293+
const uint32_t length = cstr ? strlen(cstr) : 0u;
294+
return copy(cstr, length);
294295
}
295296

296297
/*********************************************/

0 commit comments

Comments
 (0)