From 8e22c89136ea15cfc2e876380435183bcaa8059d Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Sun, 30 Oct 2022 12:45:55 +0800 Subject: [PATCH] fix: coverity scan problem for trow --- source/common/src/trow.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/common/src/trow.c b/source/common/src/trow.c index b007075efe..e4818aaa87 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -73,7 +73,13 @@ void tdSCellValPrint(SCellVal *pVal, int8_t colType) { } else if (tdValTypeIsNone(pVal->valType)) { printf("NONE "); return; + } + if(!pVal->val) { + ASSERT(0); + printf("BadVal "); + return; } + switch (colType) { case TSDB_DATA_TYPE_BOOL: printf("%s ", (*(int8_t *)pVal->val) == 0 ? "false" : "true"); @@ -678,6 +684,10 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp } // TS KEY is stored in STSRow.ts and not included in STSRow.data field. if (colId == PRIMARYKEY_TIMESTAMP_COL_ID) { + if (!val) { + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } TD_ROW_KEY(pRow) = *(TSKEY *)val; // The primary TS key is Norm all the time, thus its valType is not stored in bitmap. return TSDB_CODE_SUCCESS;