From 64cd9a079b987e1ef3daf926bd5af26185e297a5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 6 Nov 2019 17:16:46 +0100 Subject: Fix T70952: EXR files bigger than 2GB don't open on Windows --- intern/guardedalloc/intern/mmap_win.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'intern/guardedalloc') diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c index 5b0c4b6614a..3508ae4e1aa 100644 --- a/intern/guardedalloc/intern/mmap_win.c +++ b/intern/guardedalloc/intern/mmap_win.c @@ -125,8 +125,11 @@ void *mmap(void *UNUSED(start), size_t len, int prot, int flags, int fd, off_t o } } - /* note len is passed to a 32 bit DWORD, so can't be > 4 GB */ - maphandle = CreateFileMapping(fhandle, NULL, prot_flags, 0, len, NULL); + /* Split 64 bit size into low and high bits. */ + DWORD len_bits_high = len >> 32; + DWORD len_bits_low = len & 0xFFFFFFFF; + + maphandle = CreateFileMapping(fhandle, NULL, prot_flags, len_bits_high, len_bits_low, NULL); if (maphandle == 0) { errno = EBADF; return MAP_FAILED; -- cgit v1.2.3