From 0eddee63e8251d44c82ff943fd8593d3ebbea00c Mon Sep 17 00:00:00 2001 From: Jakob Hasse Date: Thu, 15 Dec 2022 15:35:00 +0800 Subject: [PATCH 1/2] bugfix(nvs_flash): fixed potential memory leak in nvs::Storage::init() --- components/nvs_flash/src/nvs_storage.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/nvs_flash/src/nvs_storage.cpp b/components/nvs_flash/src/nvs_storage.cpp index 1cf3b94859..e076998136 100644 --- a/components/nvs_flash/src/nvs_storage.cpp +++ b/components/nvs_flash/src/nvs_storage.cpp @@ -112,12 +112,14 @@ esp_err_t Storage::init(uint32_t baseSector, uint32_t sectorCount) item.getKey(entry->mName, sizeof(entry->mName)); err = item.getValue(entry->mIndex); if (err != ESP_OK) { + delete entry; return err; } - mNamespaces.push_back(entry); if (mNamespaceUsage.set(entry->mIndex, true) != ESP_OK) { + delete entry; return ESP_FAIL; } + mNamespaces.push_back(entry); itemIndex += item.span; } } From 72d59d1ced0bdbfbb5ae71d4ba99524157d40e93 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 15 Dec 2022 18:46:33 +0100 Subject: [PATCH 2/2] ci: add .cpp and .hpp files, but ignore nvs_storage.cpp * nvs_storage.cpp seems to produce a false positive --- .gitlab/ci/rules.yml | 4 ++-- tools/ci/static-analysis-rules.yml | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/rules.yml b/.gitlab/ci/rules.yml index df3515137a..a0679a9ddc 100644 --- a/.gitlab/ci/rules.yml +++ b/.gitlab/ci/rules.yml @@ -7,8 +7,8 @@ - "tools/ci/static-analysis-rules.yml" - "tools/ci/clang_tidy_dirs.txt" - - "**/*.{c,C}" - - "**/*.{h,H}" + - "**/*.{c,C,cpp}" + - "**/*.{h,H,hpp}" - "components/**/Kconfig" - "components/**/CMakeList.txt" diff --git a/tools/ci/static-analysis-rules.yml b/tools/ci/static-analysis-rules.yml index 97073f5e70..b0c7297e88 100644 --- a/tools/ci/static-analysis-rules.yml +++ b/tools/ci/static-analysis-rules.yml @@ -38,4 +38,7 @@ skip: - "components/bt/host/bluedroid/stack/btm/btm_dev.c" - "components/bt/host/bluedroid/stack/gatt/att_protocol.c" - "components/bt/host/bluedroid/stack/gatt/gatt_db.c" + - "components/bt/host/bluedroid/stack/l2cap/l2c_utils.c" - "components/wifi_provisioning/src/scheme_ble.c" + - "components/wpa_supplicant/src/rsn_supp/wpa.c" + - "components/nvs_flash/src/nvs_storage.cpp"