From 4cc087ecb0fd723f384704f15b18f9ea9a0cf4c6 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 2 Jul 2021 22:52:21 +0800 Subject: [PATCH] Hotfix/sangshuduo/td 3197 taosdemo coverity scan for master (#6725) * [TD-3197]: taosdemo and taosdump coverity scan issues. * exit if read sample file failed. Co-authored-by: Shuduo Sang --- src/kit/taosdemo/taosdemo.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 7f8818df7e..2d42cc0b56 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -4702,14 +4702,18 @@ PARSE_OVER: return ret; } -static void prepareSampleData() { +static int prepareSampleData() { for (int i = 0; i < g_Dbs.dbCount; i++) { for (int j = 0; j < g_Dbs.db[i].superTblCount; j++) { if (g_Dbs.db[i].superTbls[j].tagsFile[0] != 0) { - (void)readTagFromCsvFileToMem(&g_Dbs.db[i].superTbls[j]); + if (readTagFromCsvFileToMem(&g_Dbs.db[i].superTbls[j]) != 0) { + return -1; + } } } } + + return 0; } static void postFreeResource() { @@ -6771,7 +6775,11 @@ static int insertTestProcess() { } // pretreatement - prepareSampleData(); + if (prepareSampleData() != 0) { + if (g_fpOfInsertResult) + fclose(g_fpOfInsertResult); + return -1; + } double start; double end; -- GitLab