diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index d556ada1d2..ee6e2d71a0 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -924,6 +924,9 @@ int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { } pStmt->sql.sqlStr = strndup(sql, length); + if (!pStmt->sql.sqlStr) { + return TSDB_CODE_OUT_OF_MEMORY; + } pStmt->sql.sqlLen = length; pStmt->sql.stbInterlaceMode = pStmt->stbInterlaceMode; diff --git a/source/client/src/clientStmt2.c b/source/client/src/clientStmt2.c index 66430a2647..51d3df5de8 100644 --- a/source/client/src/clientStmt2.c +++ b/source/client/src/clientStmt2.c @@ -869,6 +869,9 @@ int stmtPrepare2(TAOS_STMT2* stmt, const char* sql, unsigned long length) { } pStmt->sql.sqlStr = strndup(sql, length); + if (!pStmt->sql.sqlStr) { + return TSDB_CODE_OUT_OF_MEMORY; + } pStmt->sql.sqlLen = length; pStmt->sql.stbInterlaceMode = pStmt->stbInterlaceMode; diff --git a/source/libs/parser/src/parInsertStmt.c b/source/libs/parser/src/parInsertStmt.c index 9f3d5b5a81..6893cb8f92 100644 --- a/source/libs/parser/src/parInsertStmt.c +++ b/source/libs/parser/src/parInsertStmt.c @@ -173,6 +173,10 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch isJson = true; char* tmp = taosMemoryCalloc(1, colLen + 1); + if (!tmp) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } memcpy(tmp, bind[c].buffer, colLen); code = parseJsontoTagData(tmp, pTagArray, &pTag, &pBuf); taosMemoryFree(tmp); @@ -513,6 +517,10 @@ int32_t qBindStmtTagsValue2(void* pBlock, void* boundTags, int64_t suid, const c isJson = true; char* tmp = taosMemoryCalloc(1, colLen + 1); + if (!tmp) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } memcpy(tmp, bind[c].buffer, colLen); code = parseJsontoTagData(tmp, pTagArray, &pTag, &pBuf); taosMemoryFree(tmp);