Discern MAP_ANONYMOUS the proper way on NT

We were checking for anonymous mappings earlier on Windows by seeing if
the file descriptor argument to mmap() was supplied as -1. This was not
correct. The proper thing to do is check `flags & MAP_ANONYMOUS`.
This commit is contained in:
Justine Tunney 2023-03-28 22:16:26 -07:00
parent 390aee960a
commit 0d084d01b9
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -38,10 +38,10 @@ textwindows struct DirectMap sys_mmap_nt(void *addr, size_t size, int prot,
struct ProtectNt fl;
const struct NtSecurityAttributes *sec;
if (fd != -1) {
handle = g_fds.p[fd].handle;
} else {
if (flags & MAP_ANONYMOUS) {
handle = kNtInvalidHandleValue;
} else {
handle = g_fds.p[fd].handle;
}
if ((flags & MAP_TYPE) != MAP_SHARED) {