From 38a481afce9304705409f12cfb3ce7440b88676d Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Sat, 18 Jun 2022 08:21:31 +0800 Subject: [PATCH] add close null pointer validate --- source/client/src/clientMain.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 20a27b1565..3e82226186 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -119,6 +119,10 @@ void taos_close_internal(void *taos) { } void taos_close(TAOS *taos) { + if (taos == NULL) { + return; + } + STscObj* pObj = acquireTscObj(*(int64_t*)taos); if (NULL == pObj) { return; @@ -209,6 +213,11 @@ static void syncQueryFn(void *param, void *res, int32_t code) { } TAOS_RES *taos_query(TAOS *taos, const char *sql) { + if (NULL == taos) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return NULL; + } + STscObj* pTscObj = acquireTscObj(*(int64_t*)taos); if (pTscObj == NULL || sql == NULL) { terrno = TSDB_CODE_TSC_DISCONNECTED; -- GitLab