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
pull/6/head
Heikki Linnakangas 12 years ago
parent 540ac7cea9
commit f35aef415a
  1. 3
      src/backend/utils/adt/ri_triggers.c

@ -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;
}
}

Loading…
Cancel
Save