mirror of
https://github.com/matrix-construct/construct
synced 2024-11-28 17:52:54 +01:00
ircd::db: Assert valid iterator prior to all relevant operations.
This commit is contained in:
parent
73a3a4cb35
commit
6e7d63ce6d
1 changed files with 22 additions and 5 deletions
27
ircd/db.cc
27
ircd/db.cc
|
@ -5179,11 +5179,24 @@ ircd::db::_seek_(rocksdb::Iterator &it,
|
|||
|
||||
switch(p)
|
||||
{
|
||||
case pos::NEXT: it.Next(); break;
|
||||
case pos::PREV: it.Prev(); break;
|
||||
case pos::FRONT: it.SeekToFirst(); break;
|
||||
case pos::BACK: it.SeekToLast(); break;
|
||||
default:
|
||||
case pos::NEXT:
|
||||
assert(valid(it));
|
||||
it.Next();
|
||||
break;
|
||||
|
||||
case pos::PREV:
|
||||
assert(valid(it));
|
||||
it.Prev();
|
||||
break;
|
||||
|
||||
case pos::FRONT:
|
||||
it.SeekToFirst();
|
||||
break;
|
||||
|
||||
case pos::BACK:
|
||||
it.SeekToLast();
|
||||
break;
|
||||
|
||||
case pos::END:
|
||||
{
|
||||
it.SeekToLast();
|
||||
|
@ -5192,6 +5205,10 @@ ircd::db::_seek_(rocksdb::Iterator &it,
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return it;
|
||||
|
|
Loading…
Reference in a new issue