aboutsummaryrefslogtreecommitdiff
path: root/libc/bionic/android_set_abort_message.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2022-04-11 16:01:37 -0700
committerChristopher Ferris <cferris@google.com>2022-04-12 13:46:48 -0700
commitbbf9cd86ca53c09d018f69105f99e24ec192310c (patch)
tree8a69cfcf0ca77ba4cac25e15a488de531bea33e3 /libc/bionic/android_set_abort_message.cpp
parentf252b7c46566b19d4ea5cee1f3246972bdb79e3c (diff)
In android_set_abort_message, check for nullptr.
If a process is failing due to out of memory, some code calls android_set_abort_message with a nullptr. Specifically, the libc++ library std::terminate can call do this. In this case, put a null in the abort message. Test: Call with nullptr and verify the code does not crash. Test: Modified crasher to set an abort message and set a null abort Test: message. Ran both, verified the abort message displays in Test: first case, and doesn't display in the second case. Change-Id: Ia9250f47e4537853ce93bbb20b35915a78caa502
Diffstat (limited to 'libc/bionic/android_set_abort_message.cpp')
-rw-r--r--libc/bionic/android_set_abort_message.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libc/bionic/android_set_abort_message.cpp b/libc/bionic/android_set_abort_message.cpp
index 2ea12ee54..d5f8cb97f 100644
--- a/libc/bionic/android_set_abort_message.cpp
+++ b/libc/bionic/android_set_abort_message.cpp
@@ -77,6 +77,10 @@ void android_set_abort_message(const char* msg) {
return;
}
+ if (msg == nullptr) {
+ msg = "(null)";
+ }
+
size_t size = sizeof(magic_abort_msg_t) + strlen(msg) + 1;
void* map = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
if (map == MAP_FAILED) {