提交 b4fde56a 编写于 作者: B Benguang Zhao

fix: resolve an issue of index out-of-range in tscBuildQueryStreamDesc etc.

上级 41543c37
...@@ -282,18 +282,8 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { ...@@ -282,18 +282,8 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
// } // }
pthread_mutex_lock(&pSql->subState.mutex); pthread_mutex_lock(&pSql->subState.mutex);
if (pSql->pSubs != NULL && pSql->subState.states != NULL) { 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 // 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]; SSqlObj *psub = pSql->pSubs[i];
int64_t self = (psub != NULL)? psub->self : 0; int64_t self = (psub != NULL)? psub->self : 0;
...@@ -306,6 +296,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { ...@@ -306,6 +296,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
p += len; p += len;
} }
} }
pQdesc->numOfSub = pSql->subState.numOfSub;
pthread_mutex_unlock(&pSql->subState.mutex); pthread_mutex_unlock(&pSql->subState.mutex);
} }
......
...@@ -357,7 +357,7 @@ void checkBrokenQueries(STscObj *pTscObj) { ...@@ -357,7 +357,7 @@ void checkBrokenQueries(STscObj *pTscObj) {
pthread_mutex_lock(&pSql->subState.mutex); pthread_mutex_lock(&pSql->subState.mutex);
if (pSql->pSubs) { if (pSql->pSubs) {
// have sub sql // have sub sql
for (int i = 0; i < numOfSub; i++) { for (int i = 0; i < pSql->subState.numOfSub; i++) {
SSqlObj *pSubSql = pSql->pSubs[i]; SSqlObj *pSubSql = pSql->pSubs[i];
if(pSubSql) { if(pSubSql) {
tscInfo("PROBE 0x%" PRIx64 " sub sql app is 0x%" PRIx64, pSql->self, pSubSql->self); tscInfo("PROBE 0x%" PRIx64 " sub sql app is 0x%" PRIx64, pSql->self, pSubSql->self);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册