Commit f35aef41 authored by Heikki Linnakangas's avatar Heikki Linnakangas

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
parent 540ac7ce
...@@ -2934,7 +2934,8 @@ InvalidateConstraintCacheCallBack(Datum arg, int cacheid, uint32 hashvalue) ...@@ -2934,7 +2934,8 @@ InvalidateConstraintCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
hash_seq_init(&status, ri_constraint_cache); hash_seq_init(&status, ri_constraint_cache);
while ((hentry = (RI_ConstraintInfo *) hash_seq_search(&status)) != NULL) 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; hentry->valid = false;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment