From daa08e610259d00de9c96953313f761dbf9a9055 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Tue, 21 Feb 2017 17:15:04 +0300 Subject: [PATCH] mdbx: assert for NODEPTR. --- mdbx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mdbx.c b/mdbx.c index 16bbab74..961cf7bb 100644 --- a/mdbx.c +++ b/mdbx.c @@ -763,7 +763,11 @@ typedef struct MDB_node { #define LEAFSIZE(k, d) (NODESIZE + (k)->mv_size + (d)->mv_size) /** Address of node \b i in page \b p */ -#define NODEPTR(p, i) ((MDB_node *)((char *)(p) + (p)->mp_ptrs[i] + PAGEBASE)) +#define NODEPTR(p, i) \ + ({ \ + assert(NUMKEYS(p) > (unsigned)(i)); \ + (MDB_node *)((char *)(p) + (p)->mp_ptrs[i] + PAGEBASE); \ + }) /** Address of the key for the node */ #define NODEKEY(node) (void *)((node)->mn_data)