Index: base/process_util_unittest.cc |
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc |
index 5a72f19c65aa6b071ae6fda3448fde0627643481..80d59d672efdfe0577fcf6486645f45026453591 100644 |
--- a/base/process_util_unittest.cc |
+++ b/base/process_util_unittest.cc |
@@ -22,12 +22,12 @@ |
#include "testing/multiprocess_func_list.h" |
#if defined(OS_LINUX) |
-#include <errno.h> |
#include <malloc.h> |
#include <glib.h> |
#include <sched.h> |
#endif |
#if defined(OS_POSIX) |
+#include <errno.h> |
#include <dlfcn.h> |
#include <fcntl.h> |
#include <signal.h> |
@@ -454,8 +454,13 @@ TEST_F(ProcessUtilTest, MacTerminateOnHeapCorruption) { |
// test suite setup and does not need to be done again, else mach_override |
// will fail. |
- char buf[3]; |
- ASSERT_DEATH(free(buf), "being freed.*" |
+ // Test that ENOMEM doesn't crash. |
+ void* buf = malloc(std::numeric_limits<size_t>::max()); |
Scott Hess - ex-Googler
2012/03/06 01:27:51
Whoa, that's super shiny!
BTW, did you see the co
Robert Sesek
2012/03/06 01:55:43
Very, very relevant. That explains the behavior I
|
+ EXPECT_FALSE(buf); |
+ EXPECT_EQ(ENOMEM, errno) << "Expected no memory error"; |
+ |
+ char stack_buf[3]; |
+ ASSERT_DEATH(free(stack_buf), "being freed.*" |
"\\*\\*\\* set a breakpoint in malloc_error_break to debug.*" |
"Terminating process due to a potential for future heap corruption"); |
} |