提交 96d4f0a7 编写于 作者: dengyihao's avatar dengyihao

[TD-11316]<fix> fix mem leak when taos_connect failed

上级 ab08e5cf
...@@ -195,6 +195,9 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, ...@@ -195,6 +195,9 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
tsem_wait(&pSql->rspSem); tsem_wait(&pSql->rspSem);
pSql->pTscObj->pClusterInfo = (SClusterInfo *)tscAcquireClusterInfo(pSql->pTscObj->clusterId); pSql->pTscObj->pClusterInfo = (SClusterInfo *)tscAcquireClusterInfo(pSql->pTscObj->clusterId);
if (pSql->pTscObj->pClusterInfo == NULL) {
assert(pSql->res.code != TSDB_CODE_SUCCESS);
}
if (pSql->res.code != TSDB_CODE_SUCCESS) { if (pSql->res.code != TSDB_CODE_SUCCESS) {
terrno = pSql->res.code; terrno = pSql->res.code;
if (terrno ==TSDB_CODE_RPC_FQDN_ERROR) { if (terrno ==TSDB_CODE_RPC_FQDN_ERROR) {
......
...@@ -133,8 +133,11 @@ void tscClusterInfoDestroy(SClusterInfo *pObj) { ...@@ -133,8 +133,11 @@ void tscClusterInfoDestroy(SClusterInfo *pObj) {
void *tscAcquireClusterInfo(const char *clusterId) { void *tscAcquireClusterInfo(const char *clusterId) {
pthread_mutex_lock(&clusterMutex); pthread_mutex_lock(&clusterMutex);
size_t len = strlen(clusterId); size_t len = strlen(clusterId);
if (len == 0) {
pthread_mutex_unlock(&clusterMutex);
return NULL;
}
SClusterInfo *pObj = NULL; SClusterInfo *pObj = NULL;
SClusterInfo **ppObj = taosHashGet(tscClusterMap, clusterId, len); SClusterInfo **ppObj = taosHashGet(tscClusterMap, clusterId, len);
if (ppObj == NULL || *ppObj == NULL) { if (ppObj == NULL || *ppObj == NULL) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册