fix:[TD-31974] fix memory leak when error occurs after mode function init.
This commit is contained in:
parent
f9c8b6cd7b
commit
d670778802
|
@ -1010,6 +1010,10 @@ static void destroySqlFunctionCtx(SqlFunctionCtx* pCtx, SExprInfo* pExpr, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
|
if (pCtx[i].fpSet.cleanup != NULL) {
|
||||||
|
pCtx[i].fpSet.cleanup(&pCtx[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (pExpr != NULL) {
|
if (pExpr != NULL) {
|
||||||
SExprInfo* pExprInfo = &pExpr[i];
|
SExprInfo* pExprInfo = &pExpr[i];
|
||||||
for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
|
for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
|
||||||
|
|
|
@ -659,10 +659,6 @@ void destroyOperator(SOperatorInfo* pOperator) {
|
||||||
freeResetOperatorParams(pOperator, OP_GET_PARAM, true);
|
freeResetOperatorParams(pOperator, OP_GET_PARAM, true);
|
||||||
freeResetOperatorParams(pOperator, OP_NOTIFY_PARAM, true);
|
freeResetOperatorParams(pOperator, OP_NOTIFY_PARAM, true);
|
||||||
|
|
||||||
if (pOperator->fpSet.closeFn != NULL && pOperator->info != NULL) {
|
|
||||||
pOperator->fpSet.closeFn(pOperator->info);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pOperator->pDownstream != NULL) {
|
if (pOperator->pDownstream != NULL) {
|
||||||
for (int32_t i = 0; i < pOperator->numOfRealDownstream; ++i) {
|
for (int32_t i = 0; i < pOperator->numOfRealDownstream; ++i) {
|
||||||
destroyOperator(pOperator->pDownstream[i]);
|
destroyOperator(pOperator->pDownstream[i]);
|
||||||
|
@ -673,6 +669,12 @@ void destroyOperator(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupExprSupp(&pOperator->exprSupp);
|
cleanupExprSupp(&pOperator->exprSupp);
|
||||||
|
|
||||||
|
// close operator after cleanup exprSupp, since we need to call cleanup of sqlFunctionCtx first to avoid mem leak.
|
||||||
|
if (pOperator->fpSet.closeFn != NULL && pOperator->info != NULL) {
|
||||||
|
pOperator->fpSet.closeFn(pOperator->info);
|
||||||
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pOperator);
|
taosMemoryFreeClear(pOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6036,9 +6036,10 @@ static void modeFunctionCleanup(SModeInfo * pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void modeFunctionCleanupExt(SqlFunctionCtx* pCtx) {
|
void modeFunctionCleanupExt(SqlFunctionCtx* pCtx) {
|
||||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
if (pCtx == NULL || GET_RES_INFO(pCtx) == NULL || GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)) == NULL) {
|
||||||
SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
return;
|
||||||
modeFunctionCleanup(pInfo);
|
}
|
||||||
|
modeFunctionCleanup(GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t saveModeTupleData(SqlFunctionCtx* pCtx, char* data, SModeInfo *pInfo, STuplePos* pPos) {
|
static int32_t saveModeTupleData(SqlFunctionCtx* pCtx, char* data, SModeInfo *pInfo, STuplePos* pPos) {
|
||||||
|
|
Loading…
Reference in New Issue