提交 5feb4106 编写于 作者: wmmhello's avatar wmmhello

[TD-6167]<fix> add null pointer protection

上级 a9673ceb
......@@ -1783,7 +1783,9 @@ int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name) {
int taos_stmt_close(TAOS_STMT* stmt) {
STscStmt* pStmt = (STscStmt*)stmt;
STMT_CHECK
if (pStmt == NULL || pStmt->taos == NULL) {
STMT_RET(TSDB_CODE_TSC_DISCONNECTED);
}
if (!pStmt->isInsert) {
SNormalStmt* normal = &pStmt->normal;
if (normal->params != NULL) {
......@@ -1812,7 +1814,7 @@ int taos_stmt_close(TAOS_STMT* stmt) {
}
}
tscFreeSqlObj(pStmt->pSql);
taos_free_result(pStmt->pSql);
tfree(pStmt);
STMT_RET(TSDB_CODE_SUCCESS);
}
......@@ -1986,6 +1988,7 @@ TAOS_RES *taos_stmt_use_result(TAOS_STMT* stmt) {
return NULL;
}
TAOS_RES* result = pStmt->pSql;
pStmt->pSql = NULL;
return result;
}
......
......@@ -465,6 +465,7 @@ void taos_stmt_use_result_query(void *taos, char *col, int type) {
TAOS_RES *result = taos_stmt_use_result(stmt);
assert(result != NULL);
print_result(result);
taos_free_result(result);
assert(taos_stmt_close(stmt) == 0);
free(params);
free(stmt_sql);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册