diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 54745951cc..df97e873aa 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -691,7 +691,7 @@ void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { convertDataBlockToUdfDataBlock(&call->block, &input); code = udf->scriptPlugin->udfScalarProcFunc(&input, &output, udf->scriptUdfCtx); freeUdfDataDataBlock(&input); - convertUdfColumnToDataBlock(&output, &response.callRsp.resultData); + if(code == 0) convertUdfColumnToDataBlock(&output, &response.callRsp.resultData); freeUdfColumn(&output); break; } diff --git a/source/libs/function/test/udf2.c b/source/libs/function/test/udf2.c index e0b08f227f..273b9c49c2 100644 --- a/source/libs/function/test/udf2.c +++ b/source/libs/function/test/udf2.c @@ -18,6 +18,7 @@ DLL_EXPORT int32_t udf2_start(SUdfInterBuf* buf) { } DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf* interBuf, SUdfInterBuf* newInterBuf) { + if(newInterBuf->buf == NULL || newInterBuf->bufLen < (sizeof(double))) return TSDB_CODE_UDF_INVALID_BUFSIZE; double sumSquares = 0; if (interBuf->numOfResult == 1) { sumSquares = *(double*)interBuf->buf;