summaryrefslogtreecommitdiffstats
path: root/src/crypto/test/malloc.cc
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2015-09-25 00:26:37 +0000
committerKenny Root <kroot@google.com>2015-09-25 00:26:37 +0000
commita04d78d392463df4e69a64360c952ffa5abd22f7 (patch)
treedc62c249d595198e0d99e43890019d21e901fbec /src/crypto/test/malloc.cc
parent1e4884f615b20946411a74e41eb9c6aa65e2d5f3 (diff)
downloadexternal_boringssl-a04d78d392463df4e69a64360c952ffa5abd22f7.zip
external_boringssl-a04d78d392463df4e69a64360c952ffa5abd22f7.tar.gz
external_boringssl-a04d78d392463df4e69a64360c952ffa5abd22f7.tar.bz2
Revert "external/boringssl: sync with upstream."
This reverts commit 1e4884f615b20946411a74e41eb9c6aa65e2d5f3. This breaks some x86 builds. Change-Id: I4d4310663ce52bc0a130e6b9dbc22b868ff4fb25
Diffstat (limited to 'src/crypto/test/malloc.cc')
-rw-r--r--src/crypto/test/malloc.cc17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/crypto/test/malloc.cc b/src/crypto/test/malloc.cc
index 898f2a7..9ffdf01 100644
--- a/src/crypto/test/malloc.cc
+++ b/src/crypto/test/malloc.cc
@@ -34,8 +34,6 @@
#if defined(__linux__) && defined(OPENSSL_GLIBC) && !defined(OPENSSL_ARM) && \
!defined(OPENSSL_AARCH64) && !defined(OPENSSL_ASAN)
-#include <errno.h>
-#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -47,14 +45,14 @@
/* This file defines overrides for the standard allocation functions that allow
* a given allocation to be made to fail for testing. If the program is run
* with MALLOC_NUMBER_TO_FAIL set to a base-10 number then that allocation will
- * return NULL. If MALLOC_BREAK_ON_FAIL is also defined then the allocation
- * will signal SIGTRAP rather than return NULL.
+ * return NULL. If MALLOC_ABORT_ON_FAIL is also defined then the allocation
+ * will abort() rather than return NULL.
*
* This code is not thread safe. */
static uint64_t current_malloc_count = 0;
static uint64_t malloc_number_to_fail = 0;
-static char failure_enabled = 0, break_on_fail = 0;
+static char failure_enabled = 0, abort_on_fail = 0;
static int in_call = 0;
extern "C" {
@@ -97,7 +95,7 @@ static int should_fail_allocation() {
std::set_new_handler(cpp_new_handler);
}
}
- break_on_fail = (NULL != getenv("MALLOC_BREAK_ON_FAIL"));
+ abort_on_fail = (NULL != getenv("MALLOC_ABORT_ON_FAIL"));
init = 1;
}
@@ -110,8 +108,8 @@ static int should_fail_allocation() {
should_fail = (current_malloc_count == malloc_number_to_fail);
current_malloc_count++;
- if (should_fail && break_on_fail) {
- raise(SIGTRAP);
+ if (should_fail && abort_on_fail) {
+ abort();
}
return should_fail;
}
@@ -120,7 +118,6 @@ extern "C" {
void *malloc(size_t size) {
if (should_fail_allocation()) {
- errno = ENOMEM;
return NULL;
}
@@ -129,7 +126,6 @@ void *malloc(size_t size) {
void *calloc(size_t num_elems, size_t size) {
if (should_fail_allocation()) {
- errno = ENOMEM;
return NULL;
}
@@ -138,7 +134,6 @@ void *calloc(size_t num_elems, size_t size) {
void *realloc(void *ptr, size_t size) {
if (should_fail_allocation()) {
- errno = ENOMEM;
return NULL;
}