aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2021-01-15 12:44:17 +0900
committerFujii Masao <fujii@postgresql.org>2021-01-15 12:46:26 +0900
commit97b025ebe6733c69a1569fd662391ad58d0616a6 (patch)
treed8d07107806cf44b1d604aafe13d23bc395f166c /src
parentbb12a7f429ca1b10aebc469d9379837fa3d09220 (diff)
downloadpostgresql-97b025ebe6733c69a1569fd662391ad58d0616a6.tar.gz
postgresql-97b025ebe6733c69a1569fd662391ad58d0616a6.zip
Fix calculation of how much shared memory is required to store a TOC.
Commit ac883ac453 refactored shm_toc_estimate() but changed its calculation of shared memory size for TOC incorrectly. Previously this could cause too large memory to be allocated. Back-patch to v11 where the bug was introduced. Author: Takayuki Tsunakawa Discussion: https://postgr.es/m/TYAPR01MB2990BFB73170E2C4921E2C4DFEA80@TYAPR01MB2990.jpnprd01.prod.outlook.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/storage/ipc/shm_toc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/storage/ipc/shm_toc.c b/src/backend/storage/ipc/shm_toc.c
index ee5ec6e3801..09b9d9905ab 100644
--- a/src/backend/storage/ipc/shm_toc.c
+++ b/src/backend/storage/ipc/shm_toc.c
@@ -265,8 +265,8 @@ shm_toc_estimate(shm_toc_estimator *e)
Size sz;
sz = offsetof(shm_toc, toc_entry);
- sz += add_size(sz, mul_size(e->number_of_keys, sizeof(shm_toc_entry)));
- sz += add_size(sz, e->space_for_chunks);
+ sz = add_size(sz, mul_size(e->number_of_keys, sizeof(shm_toc_entry)));
+ sz = add_size(sz, e->space_for_chunks);
return BUFFERALIGN(sz);
}