diff options
Diffstat (limited to 'third_party/base/allocator/partition_allocator/address_space_randomization.cc')
-rw-r--r-- | third_party/base/allocator/partition_allocator/address_space_randomization.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/third_party/base/allocator/partition_allocator/address_space_randomization.cc b/third_party/base/allocator/partition_allocator/address_space_randomization.cc index fdcc5911b9..08f22be80a 100644 --- a/third_party/base/allocator/partition_allocator/address_space_randomization.cc +++ b/third_party/base/allocator/partition_allocator/address_space_randomization.cc @@ -15,6 +15,11 @@ #include <unistd.h> #endif +// VersionHelpers.h must be included after windows.h. +#if defined(OS_WIN) +#include <VersionHelpers.h> +#endif + namespace pdfium { namespace base { @@ -90,11 +95,17 @@ void* GetRandomPageBase() { // This address mask gives a low likelihood of address space collisions. We // handle the situation gracefully if there is a collision. #if defined(OS_WIN) - // 64-bit Windows has a bizarrely small 8TB user address space. Allocates in - // the 1-5TB region. TODO(palmer): See if Windows >= 8.1 has the full 47 bits, - // and use it if so. crbug.com/672219 random &= 0x3ffffffffffUL; - random += 0x10000000000UL; + // Windows >= 8.1 has the full 47 bits. Use them where available. + static bool windows_81 = false; + static bool windows_81_initialized = false; + if (!windows_81_initialized) { + windows_81 = IsWindows8Point1OrGreater(); + windows_81_initialized = true; + } + if (!windows_81) { + random += 0x10000000000UL; + } #elif defined(MEMORY_TOOL_REPLACES_ALLOCATOR) // This range is copied from the TSan source, but works for all tools. random &= 0x007fffffffffUL; |