From 4c00225e9fe24c07f59048e7762fe7eb53d04753 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Thu, 29 Sep 2022 11:26:58 +0800 Subject: [PATCH] fix: fix coverity scan issue in tudf.c and udfd.c --- source/libs/function/src/tudf.c | 2 ++ source/libs/function/src/udfd.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index 62427e0488..060a92f864 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -1656,6 +1656,8 @@ int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) { int32_t errCode = udfcRunUdfUvTask(task, UV_TASK_CONNECT); if (errCode != 0) { fnError("failed to connect to pipe. udfName: %s, pipe: %s", udfName, (&gUdfdProxy)->udfdPipeName); + taosMemoryFree(task->session); + taosMemoryFree(task); return TSDB_CODE_UDF_PIPE_CONNECT_ERR; } diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 636f006d6e..8ff0dc15a5 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -960,7 +960,7 @@ int32_t udfdInitResidentFuncs() { char* token; while ((token = strtok_r(pSave, ",", &pSave)) != NULL) { char func[TSDB_FUNC_NAME_LEN] = {0}; - strncpy(func, token, strlen(token)); + strncpy(func, token, sizeof(func)); taosArrayPush(global.residentFuncs, func); }