From: Heikki Linnakangas Date: Tue, 13 May 2014 16:17:28 +0000 (+0300) Subject: Fix harmless access to uninitialized memory. X-Git-Tag: REL9_4_BETA2~200 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f35aef415aa755c4e99f8c0ef83f9d14dbc48bb4;p=postgresql 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 --- diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index d30847b34e..e4d7b2c34b 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/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; } }