mirror of
https://github.com/isar/libmdbx.git
synced 2025-10-23 12:08:56 +08:00
mdbx: use saturated pgno_add() to avoid overflows.
Change-Id: I70000a86a69c9b3399d0a2c345d57ca1908f2881
This commit is contained in:
@@ -1195,3 +1195,8 @@ static __inline pgno_t bytes2pgno(const MDBX_env *env, size_t bytes) {
|
||||
mdbx_assert(env, (env->me_psize >> env->me_psize2log) == 1);
|
||||
return (pgno_t)(bytes >> env->me_psize2log);
|
||||
}
|
||||
|
||||
static __inline pgno_t pgno_add(pgno_t base, pgno_t augend) {
|
||||
assert(base <= MAX_PAGENO);
|
||||
return (augend < MAX_PAGENO - base) ? base + augend : MAX_PAGENO;
|
||||
}
|
||||
|
Reference in New Issue
Block a user