diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index ec4d0e9a2962d0add56fea9bde66b62dcf95f7c4..ac62037c1d21449de49766158785c3386de28c74 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -439,7 +439,7 @@ void exprTreeFunctionNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOper } pInputs[i].numOfRows = (int16_t)numOfRows; } else if (pChild->nodeType == TSQL_NODE_VALUE) { - pChildrenOutput[i] = malloc(pChild->resultBytes); + pChildrenOutput[i] = malloc((pChild->resultBytes+1)*TSDB_NCHAR_SIZE); tVariantDump(pChild->pVal, pChildrenOutput[i], pChild->resultType, true); pInputs[i].data = pChildrenOutput[i]; pInputs[i].numOfRows = 1; @@ -1028,7 +1028,7 @@ int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) { if (!IS_VAR_DATA_TYPE(child->pVal->nType)) { return TSDB_CODE_TSC_INVALID_OPERATION; } - char* payload = malloc(child->pVal->nLen * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); + char* payload = malloc((child->pVal->nLen+1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); tVariantDump(child->pVal, payload, resultType, true); int16_t resultBytes = varDataTLen(payload); free(payload);