diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index bc472c3900b41a38c0d9ac3efaab318a8bfbabf5..c96f109bad14c37e3e3dbd96b970a27350a555b8 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -794,8 +794,8 @@ static int tdbBtreeDecodePayload(SPage *pPage, const u8 *pPayload, SCellDecoder if (nPayload <= pPage->maxLocal) { // General case without overflow pDecoder->pKey = (void *)pPayload; - if (pDecoder->pVal) { - pDecoder->pVal = (void *)(pPayload + pDecoder->vLen); + if (!pDecoder->pVal) { + pDecoder->pVal = (void *)(pPayload + pDecoder->kLen); } } diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c index 3e0d845d6d26c3da180d0f7e1993f223d7b511f0..b99d17e4dd0241c6bb362b2fa36cb9ec474535d4 100644 --- a/source/libs/tdb/src/db/tdbPage.c +++ b/source/libs/tdb/src/db/tdbPage.c @@ -137,7 +137,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell) { } memcpy(pTarget, pCell, szCell); - pTmp = pPage->pCellIdx + idx + pPage->szOffset; + pTmp = pPage->pCellIdx + idx * pPage->szOffset; memmove(pTmp, pTmp + pPage->szOffset, pPage->pFreeStart - pTmp - pPage->szOffset); TDB_PAGE_CELL_OFFSET_AT_SET(pPage, idx, pTarget - pPage->pData); TDB_PAGE_NCELLS_SET(pPage, TDB_PAGE_NCELLS(pPage) + 1);