From 48c6b97062b361245a99ab952680e5e52f869a64 Mon Sep 17 00:00:00 2001 From: GW_MC <72297530+GWMCwing@users.noreply.github.com> Date: Mon, 20 Apr 2026 15:11:56 +0800 Subject: [PATCH] fix(nvs): Close NVS handle after processing key-value pairs to prevent resource leaks --- main/io/nvs_handler.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main/io/nvs_handler.cpp b/main/io/nvs_handler.cpp index 7aed74d..f433919 100644 --- a/main/io/nvs_handler.cpp +++ b/main/io/nvs_handler.cpp @@ -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;