fix(nvs): Close NVS handle after processing key-value pairs to prevent resource leaks
This commit is contained in:
@@ -129,6 +129,7 @@ esp_err_t NVSStorageHandler::process_all(KeyValueProcessor processor, void* arg)
|
||||
// call the processor with the key and value
|
||||
std::string key_str = info.key;
|
||||
processor(arg, key_str, this->get(key_str));
|
||||
nvs_close(temp_handle);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -156,6 +157,7 @@ esp_err_t NVSStorageHandler::process_filtered(const std::string& key_prefix, Key
|
||||
}
|
||||
// call the processor with the key and value
|
||||
processor(arg, std::string(info.key), this->get(std::string(info.key)));
|
||||
nvs_close(temp_handle);
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
@@ -186,6 +188,7 @@ esp_err_t NVSStorageHandler::process_filtered(FilterFunc filter_func, KeyValuePr
|
||||
}
|
||||
// call the processor with the key and value
|
||||
processor(arg, key_str, this->get(key_str));
|
||||
nvs_close(temp_handle);
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
Reference in New Issue
Block a user