From: Hallvard Furuseth Date: Wed, 11 Dec 2013 10:57:12 +0000 (+0100) Subject: ITS#7589 Fix delete(uneven-sized MDB_DUPFIXED data). X-Git-Tag: OPENLDAP_REL_ENG_2_4_39~21^2~24 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6808abe770d916c395a20718571ff843c903af71;p=openldap ITS#7589 Fix delete(uneven-sized MDB_DUPFIXED data). Do not give uneven sizes to the sub-page and the node it lives in. --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 92db028513..5a1c1fd8df 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -6497,21 +6497,19 @@ mdb_node_shrink(MDB_page *mp, indx_t indx) MDB_node *node; MDB_page *sp, *xp; char *base; - int osize, nsize; - int delta; + int nsize, delta; indx_t i, numkeys, ptr; node = NODEPTR(mp, indx); sp = (MDB_page *)NODEDATA(node); - osize = NODEDSZ(node); - - delta = sp->mp_upper - sp->mp_lower; - SETDSZ(node, osize - delta); + delta = SIZELEFT(sp); xp = (MDB_page *)((char *)sp + delta); /* shift subpage upward */ if (IS_LEAF2(sp)) { nsize = NUMKEYS(sp) * sp->mp_pad; + if (nsize & 1) + return; /* do not make the node uneven-sized */ memmove(METADATA(xp), METADATA(sp), nsize); } else { int i; @@ -6525,6 +6523,9 @@ mdb_node_shrink(MDB_page *mp, indx_t indx) xp->mp_pad = sp->mp_pad; COPY_PGNO(xp->mp_pgno, mp->mp_pgno); + nsize = NODEDSZ(node) - delta; + SETDSZ(node, nsize); + /* shift lower nodes upward */ ptr = mp->mp_ptrs[indx]; numkeys = NUMKEYS(mp);