mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Fix uninitialized variable in dshash.c.
A bugfix for commit 8c0d7bafad
. 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
This commit is contained in:
@ -249,6 +249,7 @@ dshash_create(dsa_area *area, const dshash_parameters *params, void *arg)
|
|||||||
}
|
}
|
||||||
hash_table->buckets = dsa_get_address(area,
|
hash_table->buckets = dsa_get_address(area,
|
||||||
hash_table->control->buckets);
|
hash_table->control->buckets);
|
||||||
|
hash_table->size_log2 = hash_table->control->size_log2;
|
||||||
|
|
||||||
return hash_table;
|
return hash_table;
|
||||||
}
|
}
|
||||||
@ -280,6 +281,14 @@ dshash_attach(dsa_area *area, const dshash_parameters *params,
|
|||||||
hash_table->find_exclusively_locked = false;
|
hash_table->find_exclusively_locked = false;
|
||||||
Assert(hash_table->control->magic == DSHASH_MAGIC);
|
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;
|
return hash_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user