From 3d47697e031cb3402380fc2e856ca80a7190b3d1 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 17 Aug 2020 13:00:38 +0000 Subject: [PATCH] TD-1167, fix coverity problem about client --- src/client/src/tscSQLParser.c | 5 ++++- src/client/src/tscServer.c | 1 + src/client/src/tscSubquery.c | 28 +++++++++++++++++----------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index e5bb516ee6..c74a403a04 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1158,8 +1158,9 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t int32_t ret = exprTreeFromSqlExpr(pCmd, &pNode, pItem->pNode, pQueryInfo->exprList, pQueryInfo, colList); if (ret != TSDB_CODE_SUCCESS) { - tExprTreeDestroy(&pNode, NULL); taosTFree(arithmeticExprStr); + taosArrayDestroy(colList); + tExprTreeDestroy(&pNode, NULL); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } @@ -1168,6 +1169,8 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t SColIndex* pIndex = taosArrayGet(colList, k); if (pIndex->flag == 1) { taosTFree(arithmeticExprStr); + taosArrayDestroy(colList); + tExprTreeDestroy(&pNode, NULL); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); } } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 6b75b680b1..4c73c6d968 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -158,6 +158,7 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) { if (pRsp->killConnection) { tscKillConnection(pObj); + return; } else { if (pRsp->queryId) tscKillQuery(pObj, htonl(pRsp->queryId)); if (pRsp->streamId) tscKillStream(pObj, htonl(pRsp->streamId)); diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 75644c355c..d2b5439f8d 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -684,6 +684,8 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow freeJoinSubqueryObj(pParentSql); pParentSql->res.code = code; tscQueueAsyncRes(pParentSql); + taosArrayDestroy(s1); + taosArrayDestroy(s2); return; } @@ -1296,7 +1298,9 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) { tscError("%p tableIndex:%d, failed to allocate join support object, abort further query", pSql, i); pState->numOfRemain = i; pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY; - + if (0 == i) { + taosTFree(pState); + } return pSql->res.code; } @@ -1304,7 +1308,9 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) { if (code != TSDB_CODE_SUCCESS) { // failed to create subquery object, quit query tscDestroyJoinSupporter(pSupporter); pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY; - + if (0 == i) { + taosTFree(pState); + } break; } } @@ -2091,17 +2097,17 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) { // return; // } - tscFetchDatablockFromSubquery(pSql); - if (pRes->code != TSDB_CODE_SUCCESS) { - return; - } +// tscFetchDatablockFromSubquery(pSql); +// if (pRes->code != TSDB_CODE_SUCCESS) { +// return; +// } } - if (pSql->res.code == TSDB_CODE_SUCCESS) { - (*pSql->fp)(pSql->param, pSql, pRes->numOfRows); - } else { - tscQueueAsyncRes(pSql); - } +// if (pSql->res.code == TSDB_CODE_SUCCESS) { +// (*pSql->fp)(pSql->param, pSql, pRes->numOfRows); +// } else { +// tscQueueAsyncRes(pSql); +// } } static void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TAOS_FIELD *pField) { -- GitLab