Skip to content

Commit

Permalink
win: Get SecurityTest.CallocOverflow passing again after clang r235553.
Browse files Browse the repository at this point in the history
Previously: https://codereview.chromium.org/1064713003

BUG=467929
TBR=hans

Review URL: https://codereview.chromium.org/1105583002

Cr-Commit-Position: refs/heads/master@{#326438}
  • Loading branch information
nico authored and Commit bot committed Apr 23, 2015
1 parent a068236 commit 189ce1f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base/security_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void ExhaustMemoryWithRealloc() {
// We also use it so that the compiler doesn't discard certain return values
// as something we don't need (see the comment with calloc below).
template <typename Type>
Type HideValueFromCompiler(volatile Type value) {
NOINLINE Type HideValueFromCompiler(volatile Type value) {
#if defined(__GNUC__)
// In a GCC compatible compiler (GCC or Clang), make this compiler barrier
// more robust than merely using "volatile".
Expand Down Expand Up @@ -290,11 +290,11 @@ TEST(SecurityTest, MAYBE_NewOverflow) {
// Call calloc(), eventually free the memory and return whether or not
// calloc() did succeed.
bool CallocReturnsNull(size_t nmemb, size_t size) {
// We need the two calls to HideValueFromCompiler(): we have seen LLVM
scoped_ptr<char, base::FreeDeleter> array_pointer(
static_cast<char*>(calloc(nmemb, size)));
// We need the call to HideValueFromCompiler(): we have seen LLVM
// optimize away the call to calloc() entirely and assume the pointer to not
// be NULL.
scoped_ptr<char, base::FreeDeleter> array_pointer(
static_cast<char*>(HideValueFromCompiler(calloc(nmemb, size))));
return HideValueFromCompiler(array_pointer.get()) == NULL;
}

Expand Down

0 comments on commit 189ce1f

Please sign in to comment.