From ee94c5c089ed29a11be4d00d399788f9f97f9b95 Mon Sep 17 00:00:00 2001 From: TD-er Date: Sat, 15 Feb 2025 11:38:32 +0100 Subject: [PATCH] Fix crash in String when using nullptr (#10971) Fixes: #10971 --- cores/esp32/WString.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); } /*********************************************/