[msvc] Update csproj files (#4898)
[mono.git] / mono / utils / mono-mmap-windows.c
index 0f482d1a0901c788884b85b77f29bbbc935dc16d..0ae90eee3b9039d2c4541e17db7c7227ec991543 100644 (file)
@@ -71,6 +71,9 @@ mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type)
        int prot = mono_mmap_win_prot_from_flags (flags);
        /* translate the flags */
 
+       if (!mono_valloc_can_alloc (length))
+               return NULL;
+
        ptr = VirtualAlloc (addr, length, mflags, prot);
 
        account_mem (type, (ssize_t)length);
@@ -88,6 +91,9 @@ mono_valloc_aligned (size_t length, size_t alignment, int flags, MonoMemAccountT
        if (!mem)
                return NULL;
 
+       if (!mono_valloc_can_alloc (length))
+               return NULL;
+
        aligned = aligned_address (mem, length, alignment);
 
        aligned = VirtualAlloc (aligned, length, MEM_COMMIT, prot);