From ce61cf64d4945d170b409b5eaf4f2c96bcced8f5 Mon Sep 17 00:00:00 2001 From: Johnathon Slightham Date: Sun, 20 Jul 2025 20:55:14 -0400 Subject: [PATCH] Empty string fix --- components/config/ConfigManager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/config/ConfigManager.cpp b/components/config/ConfigManager.cpp index 34d6fbf..0678897 100644 --- a/components/config/ConfigManager.cpp +++ b/components/config/ConfigManager.cpp @@ -58,11 +58,15 @@ std::string ConfigManager::get_string(const char *key) { nvs_open(NVS_FLASH_NAMESPACE, NVS_READONLY, &config_handle); size_t required_size; // get size of the string - nvs_get_str(config_handle, key, nullptr, &required_size); + if (ESP_ERR_NVS_NOT_FOUND == nvs_get_str(config_handle, key, nullptr, &required_size)) { + return ""; + } std::string str; str.resize(required_size); - nvs_get_str(config_handle, key, str.data(), &required_size); + if (ESP_ERR_NVS_NOT_FOUND == nvs_get_str(config_handle, key, str.data(), &required_size)) { + return ""; + } nvs_close(config_handle); return str;