mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
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.
This commit is contained in:
parent
6756c8ad30
commit
343bb134ea
@ -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. */
|
/* Create new segment or open an existing one for attach. */
|
||||||
if (op == DSM_OP_CREATE)
|
if (op == DSM_OP_CREATE)
|
||||||
{
|
{
|
||||||
DWORD size_high = (DWORD) (request_size >> 32);
|
DWORD size_high;
|
||||||
DWORD size_low = (DWORD) request_size;
|
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 */
|
hmap = CreateFileMapping(INVALID_HANDLE_VALUE, /* Use the pagefile */
|
||||||
NULL, /* Default security attrs */
|
NULL, /* Default security attrs */
|
||||||
PAGE_READWRITE, /* Memory is read/write */
|
PAGE_READWRITE, /* Memory is read/write */
|
||||||
|
Loading…
Reference in New Issue
Block a user