From 22a6c4f13c95505a1d853a2479f87b054260505e Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 23 Oct 2020 12:55:43 +0800 Subject: [PATCH] [td-1373] --- src/common/src/tvariant.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c index bfd6ca0184..78d1e38f1e 100644 --- a/src/common/src/tvariant.c +++ b/src/common/src/tvariant.c @@ -147,15 +147,20 @@ void tVariantAssign(tVariant *pDst, const tVariant *pSrc) { *pDst = *pSrc; if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR) { - int32_t len = pSrc->nLen + 1; + int32_t allocLen = pSrc->nLen + 1; + int32_t len = pSrc->nLen; + if (pSrc->nType == TSDB_DATA_TYPE_NCHAR) { + allocLen = allocLen * TSDB_NCHAR_SIZE; len = len * TSDB_NCHAR_SIZE; } - char* p = realloc(pDst->pz, len); + char* p = realloc(pDst->pz, allocLen); assert(p); - memset(pDst->pz, 0, len); + memset(p, 0, allocLen); + pDst->pz = p; + memcpy(pDst->pz, pSrc->pz, len); return; } -- GitLab