From 1be31a62a8c0106a736b8f1fae7bf1deae3db8c5 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 30 Jun 2021 22:04:23 +0800 Subject: [PATCH] Hotfix/sangshuduo/td 4918 taosdemo sub afterconsume (#6685) * [TD-4918]: taosdemo subscribe endAfterResume. * fix mask length. * fix heap use-after-free. --- src/kit/taosdemo/taosdemo.c | 1 - src/mnode/src/mnodeTable.c | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 25d21b8292..5baa1f4560 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -7469,7 +7469,6 @@ static void *specifiedSubscribe(void *sarg) { } } taos_free_result(g_queryInfo.specifiedQueryInfo.res[pThreadInfo->threadID]); - taos_unsubscribe(g_queryInfo.specifiedQueryInfo.tsub[pThreadInfo->querySeq], 0); taos_close(pThreadInfo->taos); return NULL; diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index e167644413..bd1a676ea8 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -1060,7 +1060,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { pStable->info.tableId = strdup(pCreate->tableName); pStable->info.type = TSDB_SUPER_TABLE; pStable->createdTime = taosGetTimestampMs(); - int64_t x = (us&0x000000FFFFFFFFFF); + uint64_t x = (us&0x000000FFFFFFFFFF); x = x<<24; pStable->uid = x + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul)); pStable->sversion = 0; @@ -2010,7 +2010,9 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { } else { if (pTable->info.type == TSDB_SUPER_TABLE) { int64_t us = taosGetTimestampUs(); - pTable->uid = (us << 24) + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul)); + uint64_t x = (us&0x000000FFFFFFFFFF); + x = x<<24; + pTable->uid = x + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul)); } else { pTable->uid = (((uint64_t)pTable->vgId) << 48) + ((((uint64_t)pTable->tid) & ((1ul << 24) - 1ul)) << 24) + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul)); -- GitLab