fix: pSchemaExt crash

This commit is contained in:
factosea 2024-04-30 10:23:40 +08:00
parent c9415f5f85
commit 5f582723eb
4 changed files with 6 additions and 6 deletions

View File

@ -1539,7 +1539,7 @@ int32_t ctgCloneMetaOutput(STableMetaOutput* output, STableMetaOutput** pOutput)
if (output->tbMeta) { if (output->tbMeta) {
int32_t metaSize = CTG_META_SIZE(output->tbMeta); int32_t metaSize = CTG_META_SIZE(output->tbMeta);
int32_t schemaExtSize = 0; int32_t schemaExtSize = 0;
if (useCompress(output->ctbMeta.tableType)) { if (useCompress(output->tbMeta->tableType) && (*pOutput)->tbMeta->schemaExt) {
schemaExtSize = output->tbMeta->tableInfo.numOfColumns * sizeof(SSchemaExt); schemaExtSize = output->tbMeta->tableInfo.numOfColumns * sizeof(SSchemaExt);
} }
(*pOutput)->tbMeta = taosMemoryMalloc(metaSize + schemaExtSize); (*pOutput)->tbMeta = taosMemoryMalloc(metaSize + schemaExtSize);
@ -1551,7 +1551,7 @@ int32_t ctgCloneMetaOutput(STableMetaOutput* output, STableMetaOutput** pOutput)
} }
memcpy((*pOutput)->tbMeta, output->tbMeta, metaSize); 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); (*pOutput)->tbMeta->schemaExt = (SSchemaExt *)((char *)(*pOutput)->tbMeta + metaSize);
memcpy((*pOutput)->tbMeta->schemaExt, output->tbMeta->schemaExt, schemaExtSize); memcpy((*pOutput)->tbMeta->schemaExt, output->tbMeta->schemaExt, schemaExtSize);
} else { } else {

View File

@ -1225,7 +1225,7 @@ STableCfg* tableCfgDup(STableCfg* pCfg) {
SSchema* pSchema = taosMemoryMalloc(schemaSize); SSchema* pSchema = taosMemoryMalloc(schemaSize);
memcpy(pSchema, pCfg->pSchemas, schemaSize); memcpy(pSchema, pCfg->pSchemas, schemaSize);
SSchemaExt* pSchemaExt = NULL; SSchemaExt* pSchemaExt = NULL;
if (useCompress(pCfg->tableType)) { if (useCompress(pCfg->tableType) && pCfg->pSchemaExt) {
int32_t schemaExtSize = pCfg->numOfColumns * sizeof(SSchemaExt); int32_t schemaExtSize = pCfg->numOfColumns * sizeof(SSchemaExt);
pSchemaExt = taosMemoryMalloc(schemaExtSize); pSchemaExt = taosMemoryMalloc(schemaExtSize);
memcpy(pSchemaExt, pCfg->pSchemaExt, schemaExtSize); memcpy(pSchemaExt, pCfg->pSchemaExt, schemaExtSize);

View File

@ -482,7 +482,7 @@ int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst) {
int32_t metaSize = sizeof(STableMeta) + numOfField * sizeof(SSchema); int32_t metaSize = sizeof(STableMeta) + numOfField * sizeof(SSchema);
int32_t schemaExtSize = 0; int32_t schemaExtSize = 0;
if (useCompress(pSrc->tableType)) { if (useCompress(pSrc->tableType) && pSrc->schemaExt) {
schemaExtSize = pSrc->tableInfo.numOfColumns * sizeof(SSchemaExt); schemaExtSize = pSrc->tableInfo.numOfColumns * sizeof(SSchemaExt);
} }
*pDst = taosMemoryMalloc(metaSize + schemaExtSize); *pDst = taosMemoryMalloc(metaSize + schemaExtSize);

View File

@ -454,7 +454,7 @@ int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta) {
int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) { int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) {
int32_t total = msg->numOfColumns + msg->numOfTags; int32_t total = msg->numOfColumns + msg->numOfTags;
int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total; 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); STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize);
if (NULL == pTableMeta) { if (NULL == pTableMeta) {
@ -475,7 +475,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta *
pTableMeta->tableInfo.numOfColumns = msg->numOfColumns; pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total); memcpy(pTableMeta->schema, msg->pSchemas, sizeof(SSchema) * total);
if (useCompress(msg->tableType)) { if (useCompress(msg->tableType) && msg->pSchemaExt) {
pTableMeta->schemaExt = pSchemaExt; pTableMeta->schemaExt = pSchemaExt;
memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize); memcpy(pSchemaExt, msg->pSchemaExt, schemaExtSize);
} else { } else {