mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
add check to prevent crash on null strings
This commit is contained in:
@@ -25,6 +25,10 @@
|
|||||||
namespace uuid {
|
namespace uuid {
|
||||||
|
|
||||||
std::string read_flash_string(const __FlashStringHelper * flash_str) {
|
std::string read_flash_string(const __FlashStringHelper * flash_str) {
|
||||||
|
if (flash_str == nullptr) {
|
||||||
|
return std::string(""); // prevent crash
|
||||||
|
}
|
||||||
|
|
||||||
std::string str(::strlen_P(reinterpret_cast<PGM_P>(flash_str)), '\0');
|
std::string str(::strlen_P(reinterpret_cast<PGM_P>(flash_str)), '\0');
|
||||||
|
|
||||||
::strncpy_P(&str[0], reinterpret_cast<PGM_P>(flash_str), str.capacity() + 1);
|
::strncpy_P(&str[0], reinterpret_cast<PGM_P>(flash_str), str.capacity() + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user