From e182c10ce98ed49b779e904b248208c1c8acd87f Mon Sep 17 00:00:00 2001 From: Jinqing Kuang Date: Thu, 29 Aug 2024 14:18:45 +0800 Subject: [PATCH] fix(query)[TD-31499]. Fix double free on certain field memory allocation failure --- source/dnode/vnode/src/tsdb/tsdbReadUtil.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbReadUtil.c b/source/dnode/vnode/src/tsdb/tsdbReadUtil.c index 374520b483..9d58e2c7bd 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbReadUtil.c @@ -524,22 +524,12 @@ static void cleanupBlockOrderSupporter(SBlockOrderSupporter* pSup) { } static int32_t initBlockOrderSupporter(SBlockOrderSupporter* pSup, int32_t numOfTables) { - pSup->numOfBlocksPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables); - if(pSup->numOfBlocksPerTable == NULL) { - cleanupBlockOrderSupporter(pSup); - return terrno; - } - pSup->indexPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables); - if(pSup->indexPerTable == NULL) { - taosMemoryFree(pSup->numOfBlocksPerTable); - cleanupBlockOrderSupporter(pSup); - return terrno; - } pSup->pDataBlockInfo = taosMemoryCalloc(1, POINTER_BYTES * numOfTables); - if (pSup->pDataBlockInfo == NULL) { + pSup->indexPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables); + pSup->numOfBlocksPerTable = taosMemoryCalloc(1, sizeof(int32_t) * numOfTables); + pSup->numOfTables = 0; + if (pSup->pDataBlockInfo == NULL || pSup->indexPerTable == NULL || pSup->numOfBlocksPerTable == NULL) { cleanupBlockOrderSupporter(pSup); - taosMemoryFree(pSup->numOfBlocksPerTable); - taosMemoryFree(pSup->indexPerTable); return terrno; }