From 22a2f37fe5c334e7d65a6f1a3428484d3a5b754b Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Fri, 21 Oct 2022 15:50:08 +0800 Subject: [PATCH] fix: fix coverity errors --- source/libs/function/src/functionMgt.c | 6 +----- source/libs/function/src/tpercentile.c | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index ca8ddbc60a..cfe8ee71ac 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -324,7 +324,7 @@ static SFunctionNode* createFunction(const char* pName, SNodeList* pParameterLis if (NULL == pFunc) { return NULL; } - strcpy(pFunc->functionName, pName); + snprintf(pFunc->functionName, sizeof(pFunc->functionName), "%s", pName); pFunc->pParameterList = pParameterList; if (TSDB_CODE_SUCCESS != getFuncInfo(pFunc)) { pFunc->pParameterList = NULL; @@ -402,10 +402,6 @@ static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctio if (TSDB_CODE_SUCCESS == code) { *pMergeFunc = pFunc; } else { - if (NULL != pFunc) { - pFunc->pParameterList = NULL; - nodesDestroyNode((SNode*)pFunc); - } nodesDestroyList(pParameterList); } diff --git a/source/libs/function/src/tpercentile.c b/source/libs/function/src/tpercentile.c index 62c5e4b28b..6a1427c63f 100644 --- a/source/libs/function/src/tpercentile.c +++ b/source/libs/function/src/tpercentile.c @@ -96,16 +96,19 @@ double findOnlyResult(tMemBucket *pMemBucket) { } int32_t groupId = getGroupId(pMemBucket->numOfSlots, i, pMemBucket->times); - SArray *list = *(SArray **)taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId)); - assert(list->size == 1); + SArray **pList = taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId)); + if (pList != NULL) { + SArray *list = *pList; + assert(list->size == 1); - int32_t *pageId = taosArrayGet(list, 0); - SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId); - assert(pPage->num == 1); + int32_t *pageId = taosArrayGet(list, 0); + SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId); + assert(pPage->num == 1); - double v = 0; - GET_TYPED_DATA(v, double, pMemBucket->type, pPage->data); - return v; + double v = 0; + GET_TYPED_DATA(v, double, pMemBucket->type, pPage->data); + return v; + } } return 0;