diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index 071f3a6d0ec736d6faf4cf5f1347086279c0b19f..fc8872ea70d7bb4e1b0496bc678ed2a5bacf13c2 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -2229,15 +2229,15 @@ void vectorMathFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numIn } void convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec, int64_t *timeVal) { + int32_t charLen = varDataLen(inputData); + char *newColData; if (type == TSDB_DATA_TYPE_BINARY) { - int32_t charLen = varDataLen(inputData); - char *newColData = calloc(1, charLen + 1); + newColData = calloc(1, charLen + 1); memcpy(newColData, varDataVal(inputData), charLen); taosParseTime(newColData, timeVal, charLen, timePrec, 0); tfree(newColData); } else if (type == TSDB_DATA_TYPE_NCHAR) { - int32_t charLen = varDataLen(inputData); - char *newColData = calloc(1, charLen / TSDB_NCHAR_SIZE + 1); + newColData = calloc(1, charLen / TSDB_NCHAR_SIZE + 1); int len = taosUcs4ToMbs(varDataVal(inputData), charLen, newColData); if (len < 0){ uError("convertStringToTimestamp taosUcs4ToMbs error");