From b4fde56a5bd5b5ce5d5b54f95c91e1f5b331b72a Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Wed, 7 Sep 2022 15:07:36 +0800 Subject: [PATCH] fix: resolve an issue of index out-of-range in tscBuildQueryStreamDesc etc. --- src/client/src/tscProfile.c | 13 ++----------- src/client/src/tscServer.c | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index d2fdc2fc93..553c61d160 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -282,18 +282,8 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { // } pthread_mutex_lock(&pSql->subState.mutex); if (pSql->pSubs != NULL && pSql->subState.states != NULL) { - for (int32_t i = 0; i < pQdesc->numOfSub; ++i) { + for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) { // because subState maybe free on anytime by any thread, check validate from here - if(pSql->subState.numOfSub != pQdesc->numOfSub || - pSql->pSubs == NULL || - pSql->subState.states == NULL) { - tscError(" QUERY-HEART STscObj=%p subState maybe free. numOfSub=%d pSubs=%p states=%p", - pObj, pSql->subState.numOfSub, pSql->pSubs, pSql->subState.states); - pQdesc->numOfSub = 0; - // break for - break; - } - SSqlObj *psub = pSql->pSubs[i]; int64_t self = (psub != NULL)? psub->self : 0; @@ -306,6 +296,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { p += len; } } + pQdesc->numOfSub = pSql->subState.numOfSub; pthread_mutex_unlock(&pSql->subState.mutex); } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 83e8105d48..9cd36cce2b 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -357,7 +357,7 @@ void checkBrokenQueries(STscObj *pTscObj) { pthread_mutex_lock(&pSql->subState.mutex); if (pSql->pSubs) { // have sub sql - for (int i = 0; i < numOfSub; i++) { + for (int i = 0; i < pSql->subState.numOfSub; i++) { SSqlObj *pSubSql = pSql->pSubs[i]; if(pSubSql) { tscInfo("PROBE 0x%" PRIx64 " sub sql app is 0x%" PRIx64, pSql->self, pSubSql->self); -- GitLab