OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <fcntl.h> | 5 #include <fcntl.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 ASSERT_EQ(numeric_limits<size_t>::max(), kMaxSizeT); | 187 ASSERT_EQ(numeric_limits<size_t>::max(), kMaxSizeT); |
188 const size_t kArraySize2 = kMaxSizeT / kArraySize + 10; | 188 const size_t kArraySize2 = kMaxSizeT / kArraySize + 10; |
189 const size_t kDynamicArraySize2 = HideValueFromCompiler(kArraySize2); | 189 const size_t kDynamicArraySize2 = HideValueFromCompiler(kArraySize2); |
190 { | 190 { |
191 scoped_ptr<char[][kArraySize]> array_pointer(new (nothrow) | 191 scoped_ptr<char[][kArraySize]> array_pointer(new (nothrow) |
192 char[kDynamicArraySize2][kArraySize]); | 192 char[kDynamicArraySize2][kArraySize]); |
193 OverflowTestsSoftExpectTrue(!array_pointer); | 193 OverflowTestsSoftExpectTrue(!array_pointer); |
194 } | 194 } |
195 // On windows, the compiler prevents static array sizes of more than | 195 // On windows, the compiler prevents static array sizes of more than |
196 // 0x7fffffff (error C2148). | 196 // 0x7fffffff (error C2148). |
197 #if !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) | 197 #if defined(OS_WIN) && defined(ARCH_CPU_64_BITS) |
| 198 ALLOW_UNUSED_LOCAL(kDynamicArraySize); |
| 199 #else |
198 { | 200 { |
199 scoped_ptr<char[][kArraySize2]> array_pointer(new (nothrow) | 201 scoped_ptr<char[][kArraySize2]> array_pointer(new (nothrow) |
200 char[kDynamicArraySize][kArraySize2]); | 202 char[kDynamicArraySize][kArraySize2]); |
201 OverflowTestsSoftExpectTrue(!array_pointer); | 203 OverflowTestsSoftExpectTrue(!array_pointer); |
202 } | 204 } |
203 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) | 205 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) |
204 } | 206 } |
205 | 207 |
206 // Call calloc(), eventually free the memory and return whether or not | 208 // Call calloc(), eventually free the memory and return whether or not |
207 // calloc() did succeed. | 209 // calloc() did succeed. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // kRandomMask, so we use it as an additional detection mechanism. | 285 // kRandomMask, so we use it as an additional detection mechanism. |
284 const uintptr_t kRandomMask = 0x3fffffffffffULL; | 286 const uintptr_t kRandomMask = 0x3fffffffffffULL; |
285 bool impossible_random_address = | 287 bool impossible_random_address = |
286 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask; | 288 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask; |
287 EXPECT_FALSE(impossible_random_address); | 289 EXPECT_FALSE(impossible_random_address); |
288 } | 290 } |
289 | 291 |
290 #endif // defined(OS_LINUX) && defined(__x86_64__) | 292 #endif // defined(OS_LINUX) && defined(__x86_64__) |
291 | 293 |
292 } // namespace | 294 } // namespace |
OLD | NEW |