fix: cache value double free issue

This commit is contained in:
dapan1121 2024-09-02 10:22:54 +08:00
parent 0f83055786
commit 39293899e3
2 changed files with 4 additions and 3 deletions

View File

@ -744,9 +744,7 @@ _end:
insertRet = taosLRUCacheInsert(pCache->pTableMetaEntryCache, &pBlock->info.id.uid, sizeof(uint64_t), pVal,
sizeof(STableCachedVal), freeCachedMetaItem, NULL, TAOS_LRU_PRIORITY_LOW, NULL);
if (insertRet != TAOS_LRU_STATUS_OK) {
qError("failed to put meta into lru cache, code:%d, %s", insertRet, idStr);
taosMemoryFreeClear(pVal);
freeTableCachedValObj(&val);
qWarn("failed to put meta into lru cache, code:%d, %s", insertRet, idStr);
}
}

View File

@ -445,6 +445,9 @@ static LRUStatus taosLRUCacheShardInsert(SLRUCacheShard *shard, const void *key,
LRUPriority priority, void *ud) {
SLRUEntry *e = taosMemoryCalloc(1, sizeof(SLRUEntry) - 1 + keyLen);
if (!e) {
if (deleter) {
(*deleter)(key, keyLen, value, ud);
}
return TAOS_LRU_STATUS_FAIL;
}