Skip to content

Commit

Permalink
fix(NVS): return empty string when nvs_get_str failed
Browse files Browse the repository at this point in the history
  • Loading branch information
becem-gharbi committed Nov 28, 2023
1 parent edbceff commit 5bbf722
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/NVS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ namespace ESPAdmin
String NVS::getString(const char *key) const
{
size_t required_size;
nvs_get_str(_handler, key, nullptr, &required_size);
esp_err_t err = nvs_get_str(_handler, key, nullptr, &required_size);

if (err != ESP_OK)
{
return "";
}

char value[required_size];
nvs_get_str(_handler, key, value, &required_size);

Expand Down

0 comments on commit 5bbf722

Please sign in to comment.