diff options
author | Robert Haas <rhaas@postgresql.org> | 2013-10-30 09:13:42 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2013-10-30 09:14:56 -0400 |
commit | 343bb134ea20d3b7286c620c15a067da79cab724 (patch) | |
tree | ac2f8692d3b78076d618f6afdf58b2632991920a /src/backend/storage/ipc/dsm_impl.c | |
parent | 6756c8ad305f78a1d27875c3d40d3bf271cf4789 (diff) | |
download | postgresql-343bb134ea20d3b7286c620c15a067da79cab724.tar.gz postgresql-343bb134ea20d3b7286c620c15a067da79cab724.zip |
Avoid too-large shift on 32-bit Windows.
Apparently, shifts greater than or equal to the width of the type
are undefined, and can surprisingly produce a non-zero value.
Amit Kapila, with a comment by me.
Diffstat (limited to 'src/backend/storage/ipc/dsm_impl.c')
-rw-r--r-- | src/backend/storage/ipc/dsm_impl.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/backend/storage/ipc/dsm_impl.c b/src/backend/storage/ipc/dsm_impl.c index 2056668ae99..811ac0437ce 100644 --- a/src/backend/storage/ipc/dsm_impl.c +++ b/src/backend/storage/ipc/dsm_impl.c @@ -673,8 +673,17 @@ dsm_impl_windows(dsm_op op, dsm_handle handle, Size request_size, /* Create new segment or open an existing one for attach. */ if (op == DSM_OP_CREATE) { - DWORD size_high = (DWORD) (request_size >> 32); - DWORD size_low = (DWORD) request_size; + DWORD size_high; + DWORD size_low; + + /* Shifts >= the width of the type are undefined. */ +#ifdef _WIN64 + size_high = request_size >> 32; +#else + size_high = 0; +#endif + size_low = (DWORD) request_size; + hmap = CreateFileMapping(INVALID_HANDLE_VALUE, /* Use the pagefile */ NULL, /* Default security attrs */ PAGE_READWRITE, /* Memory is read/write */ |