Skip to content

Commit

Permalink
fix:memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
wangmm0220 committed Dec 18, 2024
1 parent 24f8fa4 commit ed523c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions source/libs/scalar/src/scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ void sclFreeParam(SScalarParam *param) {
taosHashCleanup(param->pHashFilter);
param->pHashFilter = NULL;
}

if (param->pHashFilterVar != NULL) {
taosHashCleanup(param->pHashFilterVar);
param->pHashFilterVar = NULL;
}
}

int32_t sclCopyValueNodeValue(SValueNode *pNode, void **res) {
Expand Down Expand Up @@ -409,6 +414,8 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
taosHashCleanup(param->pHashFilter);
param->pHashFilter = NULL;
taosHashCleanup(param->pHashFilterVar);
param->pHashFilterVar = NULL;
sclError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
return terrno;
}
Expand Down Expand Up @@ -541,14 +548,15 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList *pParamList, SScalarC
}

if (0 == *rowNum) {
taosMemoryFreeClear(paramList);
sclFreeParamList(paramList, *paramNum);
paramList = NULL;
}

*pParams = paramList;
return TSDB_CODE_SUCCESS;

_return:
taosMemoryFreeClear(paramList);
sclFreeParamList(paramList, *paramNum);
SCL_RET(code);
}

Expand Down
2 changes: 1 addition & 1 deletion source/libs/scalar/test/scalar/scalarTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,7 @@ TEST(columnTest, int_column_in_double_list) {
SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *opNode = NULL;
int32_t leftv[5] = {1, 2, 3, 4, 5};
double rightv1 = 1.1, rightv2 = 2.2, rightv3 = 3.3;
bool eRes[5] = {true, true, true, false, false};
bool eRes[5] = {false, false, false, false, false};
SSDataBlock *src = NULL;
int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]);
int32_t code = TSDB_CODE_SUCCESS;
Expand Down

0 comments on commit ed523c9

Please sign in to comment.