From c3413fd830c94e300fbbfec7e7ebfe55d7d46792 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Thu, 5 Aug 2021 10:34:24 +0800 Subject: [PATCH] fix realloc usage in tdataformat --- src/common/src/tdataformat.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 3f0ab7f93e..70911c88a6 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -357,8 +357,9 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) { int oldMaxCols = pCols->maxCols; if (schemaNCols(pSchema) > oldMaxCols) { pCols->maxCols = schemaNCols(pSchema); - pCols->cols = (SDataCol *)realloc(pCols->cols, sizeof(SDataCol) * pCols->maxCols); - if (pCols->cols == NULL) return -1; + void* ptr = (SDataCol *)realloc(pCols->cols, sizeof(SDataCol) * pCols->maxCols); + if (ptr == NULL) return -1; + pCols->cols = ptr; for(i = oldMaxCols; i < pCols->maxCols; i++) { pCols->cols[i].pData = NULL; pCols->cols[i].dataOff = NULL;