diff --git a/mmap_win32.c b/mmap_win32.c index fdf71e050..881249d14 100644 --- a/mmap_win32.c +++ b/mmap_win32.c @@ -68,16 +68,16 @@ void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset dwDesiredAccess |= FILE_MAP_COPY; void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length); if (ret == NULL) { - CloseHandle(h); ret = MAP_FAILED; } + // since we are handling the file ourselves with fd, close the Windows Handle here + CloseHandle(h); return ret; } void munmap(void *addr, size_t length) { UnmapViewOfFile(addr); - /* ruh-ro, we leaked handle from CreateFileMapping() ... */ } #undef DWORD_HI