Skip to content

Commit

Permalink
Corner case in findKey DatabaseMTAssociativeCache2
Browse files Browse the repository at this point in the history
  • Loading branch information
rickb80 committed Jul 27, 2023
1 parent b0b87c0 commit 4486b29
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/hashdb/database_associative_cache_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,10 @@ bool DatabaseMTAssociativeCache2::findKey(Goldilocks::Element (&key)[4], vector<
{
uint32_t tableIndex = (uint32_t)(key[i].fe & indicesMask);
uint32_t cacheIndex = indices[tableIndex];
if (currentCacheIndex - cacheIndex > cacheSize)
if (currentCacheIndex - cacheIndex > cacheSize ||
(currentCacheIndex < cacheSize && UINT32_MAX - cacheIndex + currentCacheIndex > cacheSize))
continue;

uint32_t cacheIndexKey = cacheIndex * 4;

if (keys[cacheIndexKey + 0].fe == key[0].fe &&
Expand Down

0 comments on commit 4486b29

Please sign in to comment.