Fix crash while reading metadata

This commit is contained in:
Vitaliy Filippov
2019-11-26 12:06:42 +03:00
parent a8f250c68f
commit a6770f619a
+2 -3
View File
@@ -80,15 +80,14 @@ int blockstore_init_meta::loop()
void blockstore_init_meta::handle_entries(struct clean_disk_entry* entries, int count, int block_order) void blockstore_init_meta::handle_entries(struct clean_disk_entry* entries, int count, int block_order)
{ {
auto end = bs->clean_db.end();
for (unsigned i = 0; i < count; i++) for (unsigned i = 0; i < count; i++)
{ {
if (entries[i].oid.inode > 0) if (entries[i].oid.inode > 0)
{ {
auto clean_it = bs->clean_db.find(entries[i].oid); auto clean_it = bs->clean_db.find(entries[i].oid);
if (clean_it == end || clean_it->second.version < entries[i].version) if (clean_it == bs->clean_db.end() || clean_it->second.version < entries[i].version)
{ {
if (clean_it != end) if (clean_it != bs->clean_db.end())
{ {
// free the previous block // free the previous block
allocator_set(bs->data_alloc, clean_it->second.version >> block_order, false); allocator_set(bs->data_alloc, clean_it->second.version >> block_order, false);