diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index d666f80fd3..44842084c5 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -1324,7 +1324,14 @@ static int32_t mndRetrieveIdx(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc pShow->pIter = taosMemoryCalloc(1, sizeof(SSmaAndTagIter)); } int32_t read = mndRetrieveSma(pReq, pShow, pBlock, rows); - if (read < rows) read += mndRetrieveTagIdx(pReq, pShow, pBlock, rows - read); + if (read < rows) { + read += mndRetrieveTagIdx(pReq, pShow, pBlock, rows - read); + } + // no more to read + if (read < rows) { + taosMemoryFree(pShow->pIter); + pShow->pIter = NULL; + } return read; } static void mndCancelRetrieveIdx(SMnode *pMnode, void *pIter) {