summaryrefslogtreecommitdiff
path: root/libc/test/src/string/memchr_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libc/test/src/string/memchr_test.cpp')
-rw-r--r--libc/test/src/string/memchr_test.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/libc/test/src/string/memchr_test.cpp b/libc/test/src/string/memchr_test.cpp
index 343958234edc..1455183e4646 100644
--- a/libc/test/src/string/memchr_test.cpp
+++ b/libc/test/src/string/memchr_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/signal_macros.h"
#include "src/string/memchr.h"
#include "test/UnitTest/Test.h"
#include <stddef.h>
@@ -120,3 +121,12 @@ TEST(LlvmLibcMemChrTest, SignedCharacterFound) {
// Should find the first character 'c'.
ASSERT_EQ(actual[0], c);
}
+
+#if defined(LIBC_ADD_NULL_CHECKS) && !defined(LIBC_HAS_SANITIZER)
+
+TEST(LlvmLibcMemChrTest, CrashOnNullPtr) {
+ ASSERT_DEATH([]() { LIBC_NAMESPACE::memchr(nullptr, 1, 1); },
+ WITH_SIGNAL(-1));
+}
+
+#endif // defined(LIBC_ADD_NULL_CHECKS) && !defined(LIBC_HAS_SANITIZER)