mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Use mul_size when multiplying by the number of parallel workers.
That way, if the result overflows size_t, you'll get an error instead of undefined behavior, which seems like a plus. This also has the effect of casting the number of workers from int to Size, which is better because it's harder to overflow int than size_t. Dilip Kumar reported this issue and provided a patch upon which this patch is based, but his version did use mul_size.
This commit is contained in:
@ -241,7 +241,8 @@ InitializeParallelDSM(ParallelContext *pcxt)
|
||||
PARALLEL_ERROR_QUEUE_SIZE,
|
||||
"parallel error queue size not buffer-aligned");
|
||||
shm_toc_estimate_chunk(&pcxt->estimator,
|
||||
PARALLEL_ERROR_QUEUE_SIZE * pcxt->nworkers);
|
||||
mul_size(PARALLEL_ERROR_QUEUE_SIZE,
|
||||
pcxt->nworkers));
|
||||
shm_toc_estimate_keys(&pcxt->estimator, 1);
|
||||
|
||||
/* Estimate how much we'll need for extension entrypoint info. */
|
||||
@ -347,7 +348,8 @@ InitializeParallelDSM(ParallelContext *pcxt)
|
||||
*/
|
||||
error_queue_space =
|
||||
shm_toc_allocate(pcxt->toc,
|
||||
PARALLEL_ERROR_QUEUE_SIZE * pcxt->nworkers);
|
||||
mul_size(PARALLEL_ERROR_QUEUE_SIZE,
|
||||
pcxt->nworkers));
|
||||
for (i = 0; i < pcxt->nworkers; ++i)
|
||||
{
|
||||
char *start;
|
||||
|
Reference in New Issue
Block a user