From 5f582723ebe67dcb0f0423baf527bd7491eab462 Mon Sep 17 00:00:00 2001 From: factosea <285808407@qq.com> Date: Tue, 30 Apr 2024 10:23:40 +0800 Subject: [PATCH] fix: pSchemaExt crash --- source/libs/catalog/src/ctgUtil.c | 4 ++-- source/libs/parser/src/parUtil.c | 2 +- source/libs/qcom/src/queryUtil.c | 2 +- source/libs/qcom/src/querymsg.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index 77725c1dda..6da1da2b52 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -1539,7 +1539,7 @@ int32_t ctgCloneMetaOutput(STableMetaOutput* output, STableMetaOutput** pOutput) if (output->tbMeta) { int32_t metaSize = CTG_META_SIZE(output->tbMeta); int32_t schemaExtSize = 0; - if (useCompress(output->ctbMeta.tableType)) { + if (useCompress(output->tbMeta->tableType) && (*pOutput)->tbMeta->schemaExt) { schemaExtSize = output->tbMeta->tableInfo.numOfColumns * sizeof(SSchemaExt); } (*pOutput)->tbMeta = taosMemoryMalloc(metaSize + schemaExtSize); @@ -1551,7 +1551,7 @@ int32_t ctgCloneMetaOutput(STableMetaOutput* output, STableMetaOutput** pOutput) } memcpy((*pOutput)->tbMeta, output->tbMeta, metaSize); - if (useCompress(output->ctbMeta.tableType)) { + if (useCompress(output->tbMeta->tableType) && (*pOutput)->tbMeta->schemaExt) { (*pOutput)->tbMeta->schemaExt = (SSchemaExt *)((char *)(*pOutput)->tbMeta + metaSize); memcpy((*pOutput)->tbMeta->schemaExt, output->tbMeta->schemaExt, schemaExtSize); } else { diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 5bd484f137..8f55850448 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -1225,7 +1225,7 @@ STableCfg* tableCfgDup(STableCfg* pCfg) { SSchema* pSchema = taosMemoryMalloc(schemaSize); memcpy(pSchema, pCfg->pSchemas, schemaSize); SSchemaExt* pSchemaExt = NULL; - if (useCompress(pCfg->tableType)) { + if (useCompress(pCfg->tableType) && pCfg->pSchemaExt) { int32_t schemaExtSize = pCfg->numOfColumns * sizeof(SSchemaExt); pSchemaExt = taosMemoryMalloc(schemaExtSize); memcpy(pSchemaExt, pCfg->pSchemaExt, schemaExtSize); diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c index 2a4bf196e2..4206c9292f 100644 --- a/source/libs/qcom/src/queryUtil.c +++ b/source/libs/qcom/src/queryUtil.c @@ -482,7 +482,7 @@ int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst) { int32_t metaSize = sizeof(STableMeta) + numOfField * sizeof(SSchema); int32_t schemaExtSize = 0; - if (useCompress(pSrc->tableType)) { + if (useCompress(pSrc->tableType) && pSrc->schemaExt) { schemaExtSize = pSrc->tableInfo.numOfColumns * sizeof(SSchemaExt); } *pDst = taosMemoryMalloc(metaSize + schemaExtSize); diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index 4af207254a..b13919e5e1 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -454,7 +454,7 @@ int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta) { int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) { int32_t total = msg->numOfColumns + msg->numOfTags; int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total; - int32_t schemaExtSize = useCompress(msg->tableType) ? sizeof(SSchemaExt) * msg->numOfColumns : 0; + int32_t schemaExtSize = (useCompress(msg->tableType) && msg->pSchemaExt) ? sizeof(SSchemaExt) * msg->numOfColumns : 0; STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize); if (NULL == pTableMeta) { @@ -475,7 +475,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta * pTableMeta->tableInfo.numOfColumns = msg->numOfColumns; memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total); - if (useCompress(msg->tableType)) { + if (useCompress(msg->tableType) && msg->pSchemaExt) { pTableMeta->schemaExt = pSchemaExt; memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize); } else {