fix(query)[TD-31499]. Fix double free on certain field memory allocation failure

This commit is contained in:
Jinqing Kuang 2024-08-29 14:18:45 +08:00
parent 63ec527e04
commit e182c10ce9
1 changed files with 4 additions and 14 deletions

View File

@ -524,22 +524,12 @@ static void cleanupBlockOrderSupporter(SBlockOrderSupporter* pSup) {
} }
static int32_t initBlockOrderSupporter(SBlockOrderSupporter* pSup, int32_t numOfTables) { 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); 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); cleanupBlockOrderSupporter(pSup);
taosMemoryFree(pSup->numOfBlocksPerTable);
taosMemoryFree(pSup->indexPerTable);
return terrno; return terrno;
} }