Skip to content

Commit

Permalink
bugfix(nvs_flash): fixed potential memory leak in nvs::Storage::init()
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjakob committed Dec 15, 2022
1 parent 2a12fab commit e6ca481
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/nvs_flash/src/nvs_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,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;
}
}
Expand Down

0 comments on commit e6ca481

Please sign in to comment.