diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 030022b0fd0109b44a6098400c5d351a8e5eeed1..12ae0ef8f5f1d55020d7d7986d7b3cccc1919e94 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -1781,6 +1781,9 @@ int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name) { int taos_stmt_close(TAOS_STMT* stmt) { STscStmt* pStmt = (STscStmt*)stmt; + if (stmt == NULL || pStmt->pSql == NULL || pStmt->taos == NULL) { + STMT_RET(TSDB_CODE_TSC_DISCONNECTED); + } if (!pStmt->isInsert) { SNormalStmt* normal = &pStmt->normal; if (normal->params != NULL) {