Merge pull request #17996 from taosdata/fix/TD-20277

fix: fix valgrind invalid read error
This commit is contained in:
dapan1121 2022-11-09 19:01:17 +08:00 committed by GitHub
commit b607f4736d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -1028,11 +1028,11 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
int32_t type = GET_PARAM_TYPE(pInput); int32_t type = GET_PARAM_TYPE(pInput);
bool tzPresent = (inputNum == 2) ? true : false; bool tzPresent = (inputNum == 2) ? true : false;
char *tz; char tz[20] = {0};
int32_t tzLen; int32_t tzLen = 0;
if (tzPresent) { if (tzPresent) {
tz = varDataVal(pInput[1].columnData->pData);
tzLen = varDataLen(pInput[1].columnData->pData); tzLen = varDataLen(pInput[1].columnData->pData);
memcpy(tz, varDataVal(pInput[1].columnData->pData), tzLen);
} }
for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { for (int32_t i = 0; i < pInput[0].numOfRows; ++i) {
@ -1071,8 +1071,10 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
int32_t len = (int32_t)strlen(buf); int32_t len = (int32_t)strlen(buf);
// add timezone string // add timezone string
if (tzLen > 0) {
snprintf(buf + len, tzLen + 1, "%s", tz); snprintf(buf + len, tzLen + 1, "%s", tz);
len += tzLen; len += tzLen;
}
if (hasFraction) { if (hasFraction) {
int32_t fracLen = (int32_t)strlen(fraction) + 1; int32_t fracLen = (int32_t)strlen(fraction) + 1;