components/nvs: fix infinite loop when loading namespaces

This commit is contained in:
Ivan Grokhotkov 2016-08-22 11:50:31 +08:00
parent f04c894123
commit 35d50643bc

View File

@ -44,6 +44,7 @@ esp_err_t Storage::init(uint32_t baseSector, uint32_t sectorCount)
return err;
}
// load namespaces list
clearNamespaces();
std::fill_n(mNamespaceUsage.data(), mNamespaceUsage.byteSize() / 4, 0);
for (auto it = mPageManager.begin(); it != mPageManager.end(); ++it) {
@ -56,6 +57,7 @@ esp_err_t Storage::init(uint32_t baseSector, uint32_t sectorCount)
item.getValue(entry->mIndex);
mNamespaces.push_back(entry);
mNamespaceUsage.set(entry->mIndex, true);
itemIndex += item.span;
}
}
mNamespaceUsage.set(0, true);