mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
add check to prevent crash on null strings
This commit is contained in:
@@ -25,6 +25,10 @@
|
||||
namespace uuid {
|
||||
|
||||
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');
|
||||
|
||||
::strncpy_P(&str[0], reinterpret_cast<PGM_P>(flash_str), str.capacity() + 1);
|
||||
|
||||
Reference in New Issue
Block a user