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);
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);