未验证 提交 9d4d08ea 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #8784 from taosdata/fix/TD-11316

[TD-11316]<fix> fix mem leak when taos_connect failed
......@@ -29,6 +29,7 @@
#include "ttimer.h"
#include "tscProfile.h"
static char clusterDefaultId[] = "clusterDefaultId";
static bool validImpl(const char* str, size_t maxsize) {
if (str == NULL) {
return false;
......@@ -193,7 +194,9 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
tscBuildAndSendRequest(pSql, NULL);
tsem_wait(&pSql->rspSem);
if (0 == strlen(pSql->pTscObj->clusterId)) {
memcpy(pSql->pTscObj->clusterId, clusterDefaultId, strlen(clusterDefaultId));
}
pSql->pTscObj->pClusterInfo = (SClusterInfo *)tscAcquireClusterInfo(pSql->pTscObj->clusterId);
if (pSql->res.code != TSDB_CODE_SUCCESS) {
terrno = pSql->res.code;
......
......@@ -133,8 +133,8 @@ void tscClusterInfoDestroy(SClusterInfo *pObj) {
void *tscAcquireClusterInfo(const char *clusterId) {
pthread_mutex_lock(&clusterMutex);
size_t len = strlen(clusterId);
SClusterInfo *pObj = NULL;
SClusterInfo **ppObj = taosHashGet(tscClusterMap, clusterId, len);
if (ppObj == NULL || *ppObj == NULL) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册