From 7b900a5dd120b20380a68bfa13b84b18e3b7e2a7 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 10 Apr 2020 22:50:31 +0800 Subject: [PATCH] check null pointer in tscSql.c. --- src/client/src/tscSql.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 199b4150e8..f2a3cdcab0 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -329,7 +329,10 @@ int taos_num_fields(TAOS_RES *res) { } SFieldInfo *pFieldsInfo = &pQueryInfo->fieldsInfo; - return (pFieldsInfo->numOfOutputCols - pFieldsInfo->numOfHiddenCols); + if (pFieldsInfo) + return (pFieldsInfo->numOfOutputCols - pFieldsInfo->numOfHiddenCols); + else + return 0; } int taos_field_count(TAOS *taos) { @@ -351,7 +354,11 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) { if (pSql == NULL || pSql->signature != pSql) return 0; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); - return pQueryInfo->fieldsInfo.pFields; + + if (pQueryInfo) + return pQueryInfo->fieldsInfo.pFields; + else + return NULL; } int taos_retrieve(TAOS_RES *res) { @@ -401,6 +408,9 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) { } SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); + if (pQueryInfo == NULL) + return 0; + for (int i = 0; i < pQueryInfo->fieldsInfo.numOfOutputCols; ++i) { pRes->tsrow[i] = TSC_GET_RESPTR_BASE(pRes, pQueryInfo, i); } -- GitLab