Merge pull request #27924 from taosdata/fix/TD-32146

fix(stmt): return oom if mem alloc failed
This commit is contained in:
Hongze Cheng 2024-09-18 16:46:23 +08:00 committed by GitHub
commit f1d7e2a708
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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);