ircd::db: Assert valid iterator prior to all relevant operations.

This commit is contained in:
Jason Volk 2023-04-15 15:12:27 -07:00
parent 73a3a4cb35
commit 6e7d63ce6d
1 changed files with 22 additions and 5 deletions

View File

@ -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;