Merge pull request #27596 from taosdata/fix/TD-31826

fix: cache value double free issue
This commit is contained in:
Pan Wei 2024-09-02 13:24:04 +08:00 committed by GitHub
commit 4e239a5b76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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;
}