From 8b50b282b4b090622768da320284be1680a7f282 Mon Sep 17 00:00:00 2001 From: sima Date: Sat, 20 Jul 2024 19:29:24 +0800 Subject: [PATCH] enh:[TD-31043] Handling return value in tavgfunction.c --- source/libs/function/src/detail/tavgfunction.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/libs/function/src/detail/tavgfunction.c b/source/libs/function/src/detail/tavgfunction.c index 3b8cf6e6b5..6667e84bed 100644 --- a/source/libs/function/src/detail/tavgfunction.c +++ b/source/libs/function/src/detail/tavgfunction.c @@ -853,14 +853,17 @@ int32_t avgPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t resultBytes = getAvgInfoSize(); char* res = taosMemoryCalloc(resultBytes + VARSTR_HEADER_SIZE, sizeof(char)); - memcpy(varDataVal(res), pInfo, resultBytes); + if (NULL == res) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (void)memcpy(varDataVal(res), pInfo, resultBytes); varDataSetLen(res, resultBytes); int32_t slotId = pCtx->pExpr->base.resSchema.slotId; SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); - colDataSetVal(pCol, pBlock->info.rows, res, false); + int32_t code = colDataSetVal(pCol, pBlock->info.rows, res, false); taosMemoryFree(res); - return TSDB_CODE_SUCCESS; + return code; }