diff --git a/cores/esp32/WString.cpp b/cores/esp32/WString.cpp index 5296a2d9652..18e64767545 100644 --- a/cores/esp32/WString.cpp +++ b/cores/esp32/WString.cpp @@ -290,7 +290,8 @@ String &String::operator=(StringSumHelper &&rval) { #endif String &String::operator=(const char *cstr) { - return copy(cstr, strlen(cstr)); + const uint32_t length = cstr ? strlen(cstr) : 0u; + return copy(cstr, length); } /*********************************************/