Index: src/d8.cc |
diff --git a/src/d8.cc b/src/d8.cc |
index ff90a320ff2d8e725fa53ac69c0993e904c10082..f6c13c755278ea59c3305069bb8aff236bc27844 100644 |
--- a/src/d8.cc |
+++ b/src/d8.cc |
@@ -76,10 +76,13 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
if (RoundToPageSize(&length)) { |
void* data = VirtualMemoryAllocate(length); |
#if DEBUG |
- // In debug mode, check the memory is zero-initialized. |
- uint8_t* ptr = reinterpret_cast<uint8_t*>(data); |
- for (size_t i = 0; i < length; i++) { |
- DCHECK_EQ(0, ptr[i]); |
+ if (data) { |
+ // In debug mode, check the memory is zero-initialized. |
+ size_t limit = length / sizeof(uint64_t); |
+ uint64_t* ptr = reinterpret_cast<uint64_t*>(data); |
+ for (size_t i = 0; i < limit; i++) { |
+ DCHECK_EQ(0u, ptr[i]); |
+ } |
} |
#endif |
return data; |