diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index d7325d8a253..c246e4bf0d2 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -2396,15 +2396,26 @@ int32_t initCb(void* thrd, SCliReq* pReq, STransMsg* pResp) { } return cliMayCvtFqdnToIp(pReq->ctx->epSet, pThrd->pCvtAddr); } + +static void freeUserCtx(SCliReq* pReq) { + if (!pReq || !pReq->ctx) { + return; + } + transCtxCleanup(&pReq->ctx->userCtx); +} + int32_t notifyExceptCb(void* thrd, SCliReq* pReq, STransMsg* pResp) { SCliThrd* pThrd = thrd; STrans* pInst = pThrd->pInst; int32_t code = cliBuildExceptResp(pThrd, pReq, pResp); if (code != 0) { + freeUserCtx(pReq); destroyReq(pReq); return code; } pInst->cfp(pInst->parent, pResp, NULL); + + freeUserCtx(pReq); destroyReq(pReq); return code; } @@ -4246,7 +4257,6 @@ int32_t transAllocHandle(int64_t* refId) { if (exh == NULL) { return terrno; } - exh->refId = transAddExHandle(transGetRefMgt(), exh); if (exh->refId < 0) { taosMemoryFree(exh); diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 546b1ee3acc..1f37e0d1df7 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -513,6 +513,8 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) { } taosHashCleanup(src->args); + src->args = NULL; + src->brokenVal.val = NULL; } void* transCtxDumpVal(STransCtx* ctx, int32_t key) { if (ctx->args == NULL) {