Merge pull request #27020 from taosdata/fix/TD-31237

fix(tsdb/cache): return oom with null array init
This commit is contained in:
Hongze Cheng 2024-08-07 10:11:01 +08:00 committed by GitHub
commit c87773828a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 0 deletions

View File

@ -1411,6 +1411,11 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
if (IS_LAST_KEY(idxKey->key)) {
if (NULL == lastTmpIndexArray) {
lastTmpIndexArray = taosArrayInit(num_keys, sizeof(int32_t));
if (!lastTmpIndexArray) {
taosArrayDestroy(lastrowTmpIndexArray);
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
}
}
(void)taosArrayPush(lastTmpIndexArray, &(i));
lastColIds[lastIndex] = idxKey->key.cid;
@ -1419,6 +1424,11 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
} else {
if (NULL == lastrowTmpIndexArray) {
lastrowTmpIndexArray = taosArrayInit(num_keys, sizeof(int32_t));
if (!lastrowTmpIndexArray) {
taosArrayDestroy(lastTmpIndexArray);
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
}
}
(void)taosArrayPush(lastrowTmpIndexArray, &(i));
lastrowColIds[lastrowIndex] = idxKey->key.cid;
@ -1428,6 +1438,11 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
}
pTmpColArray = taosArrayInit(lastIndex + lastrowIndex, sizeof(SLastCol));
if (!pTmpColArray) {
taosArrayDestroy(lastrowTmpIndexArray);
taosArrayDestroy(lastTmpIndexArray);
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
}
if (lastTmpIndexArray != NULL) {
(void)mergeLastCid(uid, pTsdb, &lastTmpColArray, pr, lastColIds, lastIndex, lastSlotIds);