Skip to content

Commit f35aef4

Browse files
committed
Fix harmless access to uninitialized memory.
When cache invalidations arrive while ri_LoadConstraintInfo() is busy filling a new cache entry, InvalidateConstraintCacheCallBack() compares the - not yet initialized - oidHashValue field with the to-be-invalidated hash value. To fix, check whether the entry is already marked as invalid. Andres Freund
1 parent 540ac7c commit f35aef4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/utils/adt/ri_triggers.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2934,7 +2934,8 @@ InvalidateConstraintCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
29342934
hash_seq_init(&status, ri_constraint_cache);
29352935
while ((hentry = (RI_ConstraintInfo *) hash_seq_search(&status)) != NULL)
29362936
{
2937-
if (hashvalue == 0 || hentry->oidHashValue == hashvalue)
2937+
if (hentry->valid &&
2938+
(hashvalue == 0 || hentry->oidHashValue == hashvalue))
29382939
hentry->valid = false;
29392940
}
29402941
}

0 commit comments

Comments
 (0)