From 819d1d967a8db5820f21cd02493ca2db43803b6b Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 25 Aug 2021 18:29:30 +0800 Subject: [PATCH] [TD-6167] fix memory leak --- src/client/src/tscPrepare.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index e576afb604..e607e11891 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -1503,6 +1503,14 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) { return NULL; } + if (TSDB_CODE_SUCCESS != tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE)) { + free(pSql); + free(pStmt); + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscError("failed to malloc payload buffer"); + return NULL; + } + tsem_init(&pSql->rspSem, 0, 0); pSql->signature = pSql; pSql->pTscObj = pObj; -- GitLab