fix(tsdb/cache): return oom with null array init

This commit is contained in:
Minglei Jin 2024-08-06 19:05:50 +08:00
parent 6fd580e476
commit c170cb4cf9
1 changed files with 6 additions and 0 deletions

View File

@ -1411,6 +1411,9 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
if (IS_LAST_KEY(idxKey->key)) { if (IS_LAST_KEY(idxKey->key)) {
if (NULL == lastTmpIndexArray) { if (NULL == lastTmpIndexArray) {
lastTmpIndexArray = taosArrayInit(num_keys, sizeof(int32_t)); lastTmpIndexArray = taosArrayInit(num_keys, sizeof(int32_t));
if (!lastTmpIndexArray) {
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
}
} }
(void)taosArrayPush(lastTmpIndexArray, &(i)); (void)taosArrayPush(lastTmpIndexArray, &(i));
lastColIds[lastIndex] = idxKey->key.cid; lastColIds[lastIndex] = idxKey->key.cid;
@ -1419,6 +1422,9 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
} else { } else {
if (NULL == lastrowTmpIndexArray) { if (NULL == lastrowTmpIndexArray) {
lastrowTmpIndexArray = taosArrayInit(num_keys, sizeof(int32_t)); lastrowTmpIndexArray = taosArrayInit(num_keys, sizeof(int32_t));
if (!lastrowTmpIndexArray) {
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
}
} }
(void)taosArrayPush(lastrowTmpIndexArray, &(i)); (void)taosArrayPush(lastrowTmpIndexArray, &(i));
lastrowColIds[lastrowIndex] = idxKey->key.cid; lastrowColIds[lastrowIndex] = idxKey->key.cid;