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
This commit is contained in:
Heikki Linnakangas 2014-05-13 19:17:28 +03:00
parent 540ac7cea9
commit f35aef415a
1 changed files with 2 additions and 1 deletions

View File

@ -2934,7 +2934,8 @@ InvalidateConstraintCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
hash_seq_init(&status, ri_constraint_cache);
while ((hentry = (RI_ConstraintInfo *) hash_seq_search(&status)) != NULL)
{
if (hashvalue == 0 || hentry->oidHashValue == hashvalue)
if (hentry->valid &&
(hashvalue == 0 || hentry->oidHashValue == hashvalue))
hentry->valid = false;
}
}