Skip to content

Commit 343bb13

Browse files
committed
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.
1 parent 6756c8a commit 343bb13

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/backend/storage/ipc/dsm_impl.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,17 @@ dsm_impl_windows(dsm_op op, dsm_handle handle, Size request_size,
673673
/* Create new segment or open an existing one for attach. */
674674
if (op == DSM_OP_CREATE)
675675
{
676-
DWORD size_high = (DWORD) (request_size >> 32);
677-
DWORD size_low = (DWORD) request_size;
676+
DWORD size_high;
677+
DWORD size_low;
678+
679+
/* Shifts >= the width of the type are undefined. */
680+
#ifdef _WIN64
681+
size_high = request_size >> 32;
682+
#else
683+
size_high = 0;
684+
#endif
685+
size_low = (DWORD) request_size;
686+
678687
hmap = CreateFileMapping(INVALID_HANDLE_VALUE, /* Use the pagefile */
679688
NULL, /* Default security attrs */
680689
PAGE_READWRITE, /* Memory is read/write */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy