summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthakis <thakis@chromium.org>2016-02-24 14:12:37 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-24 22:14:13 +0000
commitfdc6e5fdae6311b97e1e528dc4b9b8cd9d47a0b8 (patch)
tree3a43b230b2082ffabf1d6aa360975ec239cf16f6
parentcac80a14f7d1e275e985c70b8b734c094bea5b76 (diff)
downloadchromium_src-fdc6e5fdae6311b97e1e528dc4b9b8cd9d47a0b8.zip
chromium_src-fdc6e5fdae6311b97e1e528dc4b9b8cd9d47a0b8.tar.gz
chromium_src-fdc6e5fdae6311b97e1e528dc4b9b8cd9d47a0b8.tar.bz2
Try to get ToolsSanityTests passing with trunk clang again.
BUG=589482 Review URL: https://codereview.chromium.org/1727903003 Cr-Commit-Position: refs/heads/master@{#377401}
-rw-r--r--base/debug/asan_invalid_access.cc37
1 files changed, 17 insertions, 20 deletions
diff --git a/base/debug/asan_invalid_access.cc b/base/debug/asan_invalid_access.cc
index 0abde8c..ba0a10b 100644
--- a/base/debug/asan_invalid_access.cc
+++ b/base/debug/asan_invalid_access.cc
@@ -60,36 +60,33 @@ NOINLINE void CorruptMemoryBlock(bool induce_crash) {
static const size_t kArraySize = 5;
void AsanHeapOverflow() {
- scoped_ptr<int[]> array(new int[kArraySize]);
- // Declares the dummy value as volatile to make sure it doesn't get optimized
- // away.
- int volatile dummy = 0;
- dummy = array[kArraySize];
- base::debug::Alias(const_cast<int*>(&dummy));
+ // Declares the array as volatile to make sure it doesn't get optimized away.
+ scoped_ptr<volatile int[]> array(
+ const_cast<volatile int*>(new int[kArraySize]));
+ int dummy = array[kArraySize];
+ base::debug::Alias(&dummy);
}
void AsanHeapUnderflow() {
- scoped_ptr<int[]> array(new int[kArraySize]);
- // Declares the dummy value as volatile to make sure it doesn't get optimized
- // away.
- int volatile dummy = 0;
+ // Declares the array as volatile to make sure it doesn't get optimized away.
+ scoped_ptr<volatile int[]> array(
+ const_cast<volatile int*>(new int[kArraySize]));
// We need to store the underflow address in a temporary variable as trying to
// access array[-1] will trigger a warning C4245: "conversion from 'int' to
// 'size_t', signed/unsigned mismatch".
- int* underflow_address = &array[0] - 1;
- dummy = *underflow_address;
- base::debug::Alias(const_cast<int*>(&dummy));
+ volatile int* underflow_address = &array[0] - 1;
+ int dummy = *underflow_address;
+ base::debug::Alias(&dummy);
}
void AsanHeapUseAfterFree() {
- scoped_ptr<int[]> array(new int[kArraySize]);
- // Declares the dummy value as volatile to make sure it doesn't get optimized
- // away.
- int volatile dummy = 0;
- int* dangling = array.get();
+ // Declares the array as volatile to make sure it doesn't get optimized away.
+ scoped_ptr<volatile int[]> array(
+ const_cast<volatile int*>(new int[kArraySize]));
+ volatile int* dangling = array.get();
array.reset();
- dummy = dangling[kArraySize / 2];
- base::debug::Alias(const_cast<int*>(&dummy));
+ int dummy = dangling[kArraySize / 2];
+ base::debug::Alias(&dummy);
}
#endif // ADDRESS_SANITIZER || SYZYASAN