1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-17 21:35:45 +02:00

roots: make sure transid_max's computed value isn't max

We check the result of transid_max_nocache(), but not the result of
transid_max().  The latter is a computed result that is even more likely
to be wrong[citation needed].

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2023-02-06 22:46:46 -05:00
parent 9b60f2b94d
commit 717bdf5eb5

View File

@ -515,7 +515,12 @@ BeesRoots::transid_max_nocache()
uint64_t
BeesRoots::transid_max()
{
return m_transid_re.count();
const auto rv = m_transid_re.count();
// transid must be greater than zero, or we did something very wrong
THROW_CHECK1(runtime_error, rv, rv > 0);
// transid must be less than max, or we did something very wrong
THROW_CHECK1(runtime_error, rv, rv < numeric_limits<uint64_t>::max());
return rv;
}
struct BeesFileCrawl {