Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0fb9e4a

Browse files
committed
Fix uninitialized variable in dshash.c.
A bugfix for commit 8c0d7ba. 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
1 parent a1924a4 commit 0fb9e4a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/backend/lib/dshash.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ dshash_create(dsa_area *area, const dshash_parameters *params, void *arg)
249249
}
250250
hash_table->buckets = dsa_get_address(area,
251251
hash_table->control->buckets);
252+
hash_table->size_log2 = hash_table->control->size_log2;
252253

253254
return hash_table;
254255
}
@@ -280,6 +281,14 @@ dshash_attach(dsa_area *area, const dshash_parameters *params,
280281
hash_table->find_exclusively_locked = false;
281282
Assert(hash_table->control->magic == DSHASH_MAGIC);
282283

284+
/*
285+
* These will later be set to the correct values by
286+
* ensure_valid_bucket_pointers(), at which time we'll be holding a
287+
* partition lock for interlocking against concurrent resizing.
288+
*/
289+
hash_table->buckets = NULL;
290+
hash_table->size_log2 = 0;
291+
283292
return hash_table;
284293
}
285294

0 commit comments

Comments
 (0)