stmt: return oom if mem alloc failed

This commit is contained in:
Minglei Jin 2024-09-18 13:52:34 +08:00
parent 4c459155f1
commit 4d4f73de4e
3 changed files with 14 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);