diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-05-13 19:17:28 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-05-13 19:18:28 +0300 |
commit | f35aef415aa755c4e99f8c0ef83f9d14dbc48bb4 (patch) | |
tree | 7ebfaee90aff388ea10c3c4ec9556603818f3134 /src/backend/utils/adt/ri_triggers.c | |
parent | 540ac7cea919623f691b20892ccc50e5e33b5009 (diff) | |
download | postgresql-f35aef415aa755c4e99f8c0ef83f9d14dbc48bb4.tar.gz postgresql-f35aef415aa755c4e99f8c0ef83f9d14dbc48bb4.zip |
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
Diffstat (limited to 'src/backend/utils/adt/ri_triggers.c')
-rw-r--r-- | src/backend/utils/adt/ri_triggers.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index d30847b34e6..e4d7b2c34b6 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; } } |