diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 48c1a39a47..375092a5cf 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -8477,7 +8477,10 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) { size_t len = strlen(name); - taosHashGetCloneExt(tscTableMetaMap, name, len, NULL, (void **)&pTableMeta, &tableMetaCapacity); + if (NULL == taosHashGetCloneExt(tscTableMetaMap, name, len, NULL, (void **)&pTableMeta, &tableMetaCapacity)) { + // not found + tfree(pTableMeta); + } if (pTableMeta && pTableMeta->id.uid > 0) { tscDebug("0x%"PRIx64" retrieve table meta %s from local buf", pSql->self, name); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 783c7a3dbe..e7ba336f26 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2951,7 +2951,9 @@ int32_t tscGetTableMetaImpl(SSqlObj* pSql, STableMetaInfo *pTableMetaInfo, bool if (pTableMetaInfo->tableMetaCapacity != 0 && pTableMetaInfo->pTableMeta != NULL) { memset(pTableMetaInfo->pTableMeta, 0, pTableMetaInfo->tableMetaCapacity); } - taosHashGetCloneExt(tscTableMetaMap, name, len, NULL, (void **)&(pTableMetaInfo->pTableMeta), &pTableMetaInfo->tableMetaCapacity); + if (NULL == taosHashGetCloneExt(tscTableMetaMap, name, len, NULL, (void **)&(pTableMetaInfo->pTableMeta), &pTableMetaInfo->tableMetaCapacity)) { + tfree(pTableMetaInfo->pTableMeta); + } STableMeta* pMeta = pTableMetaInfo->pTableMeta; STableMeta* pSTMeta = (STableMeta *)(pSql->pBuf); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index ff1ba6af17..1cdada64a2 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -4469,8 +4469,11 @@ int32_t tscCreateTableMetaFromSTableMeta(STableMeta** ppChild, const char* name, if (p != NULL && sz != 0) { memset((char *)p, 0, sz); } - taosHashGetCloneExt(tscTableMetaMap, pChild->sTableName, strnlen(pChild->sTableName, TSDB_TABLE_FNAME_LEN), NULL, (void **)&p, &sz); - *ppSTable = p; + if (NULL == taosHashGetCloneExt(tscTableMetaMap, pChild->sTableName, strnlen(pChild->sTableName, TSDB_TABLE_FNAME_LEN), NULL, (void **)&p, &sz)) { + tfree(p); + } else { + *ppSTable = p; + } // tableMeta exists, build child table meta according to the super table meta // the uid need to be checked in addition to the general name of the super table.