diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 543e06aae6..26652cfffb 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -2473,12 +2473,13 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { } int tdbBtcClose(SBTC *pBtc) { - if (pBtc->freeTxn) { - tdbTxnClose(pBtc->pTxn); + if (pBtc->iPage < 0) { + if (pBtc->freeTxn) { + tdbTxnClose(pBtc->pTxn); + } + return 0; } - if (pBtc->iPage < 0) return 0; - for (;;) { if (NULL == pBtc->pPage) { tdbError("tdb/btc-close: null ptr pPage."); @@ -2500,6 +2501,10 @@ int tdbBtcClose(SBTC *pBtc) { tdbFree(pBtc->coder.pVal); } + if (pBtc->freeTxn) { + tdbTxnClose(pBtc->pTxn); + } + return 0; }