fix(tsdb/cache): Not free zero length var data

This commit is contained in:
Minglei Jin 2023-02-14 10:20:55 +08:00
parent ee9c59dc77
commit 8ec5df8d7d
1 changed files with 4 additions and 2 deletions

View File

@ -279,6 +279,7 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST
SLastCol lastCol = {.ts = keyTs, .colVal = colVal}; SLastCol lastCol = {.ts = keyTs, .colVal = colVal};
if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) { if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) {
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol); SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol);
if (pLastCol->colVal.value.nData > 0 && NULL != pLastCol->colVal.value.pData)
taosMemoryFree(pLastCol->colVal.value.pData); taosMemoryFree(pLastCol->colVal.value.pData);
lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData); lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData);
@ -361,6 +362,7 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb
SLastCol lastCol = {.ts = keyTs, .colVal = colVal}; SLastCol lastCol = {.ts = keyTs, .colVal = colVal};
if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) { if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) {
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol); SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol);
if (pLastCol->colVal.value.nData > 0 && NULL != pLastCol->colVal.value.pData)
taosMemoryFree(pLastCol->colVal.value.pData); taosMemoryFree(pLastCol->colVal.value.pData);
lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData); lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData);