aboutsummaryrefslogtreecommitdiff
path: root/src/backend/lib/dshash.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2017-09-18 17:43:37 -0700
committerAndres Freund <andres@anarazel.de>2017-09-18 17:43:37 -0700
commit0fb9e4ace5ce4d479d839a720f32b99fdc87f455 (patch)
tree5d3ba82f4b6cb1f0619dd0771a62b4b18ba0ab5c /src/backend/lib/dshash.c
parenta1924a4ea29399111e5155532ca24c9c51d3c82d (diff)
downloadpostgresql-0fb9e4ace5ce4d479d839a720f32b99fdc87f455.tar.gz
postgresql-0fb9e4ace5ce4d479d839a720f32b99fdc87f455.zip
Fix uninitialized variable in dshash.c.
A bugfix for commit 8c0d7bafad36434cb08ac2c78e69ae72c194ca20. The code would have crashed if hashtable->size_log2 ever had the same value as hashtable->control->size_log2 by coincidence. Per Valgrind. Author: Thomas Munro Reported-By: Tomas Vondra Discussion: https://postgr.es/m/e72fb33c-4f31-f276-e972-263d9b59554d%402ndquadrant.com
Diffstat (limited to 'src/backend/lib/dshash.c')
-rw-r--r--src/backend/lib/dshash.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/backend/lib/dshash.c b/src/backend/lib/dshash.c
index 448e0587253..dd875730670 100644
--- a/src/backend/lib/dshash.c
+++ b/src/backend/lib/dshash.c
@@ -249,6 +249,7 @@ dshash_create(dsa_area *area, const dshash_parameters *params, void *arg)
}
hash_table->buckets = dsa_get_address(area,
hash_table->control->buckets);
+ hash_table->size_log2 = hash_table->control->size_log2;
return hash_table;
}
@@ -280,6 +281,14 @@ dshash_attach(dsa_area *area, const dshash_parameters *params,
hash_table->find_exclusively_locked = false;
Assert(hash_table->control->magic == DSHASH_MAGIC);
+ /*
+ * These will later be set to the correct values by
+ * ensure_valid_bucket_pointers(), at which time we'll be holding a
+ * partition lock for interlocking against concurrent resizing.
+ */
+ hash_table->buckets = NULL;
+ hash_table->size_log2 = 0;
+
return hash_table;
}