diff options
Diffstat (limited to 'libc/test/src/string/stpncpy_test.cpp')
| -rw-r--r-- | libc/test/src/string/stpncpy_test.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libc/test/src/string/stpncpy_test.cpp b/libc/test/src/string/stpncpy_test.cpp index 247fa92a0c7b..f5c61e277f66 100644 --- a/libc/test/src/string/stpncpy_test.cpp +++ b/libc/test/src/string/stpncpy_test.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "hdr/signal_macros.h" #include "src/__support/CPP/span.h" #include "src/string/stpncpy.h" #include "test/UnitTest/Test.h" @@ -71,3 +72,12 @@ TEST_F(LlvmLibcStpncpyTest, CopyTwoWithNull) { const char expected[] = {'x', '\0'}; check_stpncpy(dst, src, 2, expected, 1); } + +#if defined(LIBC_ADD_NULL_CHECKS) && !defined(LIBC_HAS_SANITIZER) + +TEST_F(LlvmLibcStpncpyTest, CrashOnNullPtr) { + ASSERT_DEATH([]() { LIBC_NAMESPACE::stpncpy(nullptr, nullptr, 1); }, + WITH_SIGNAL(-1)); +} + +#endif // defined(LIBC_ADD_NULL_CHECKS) && !defined(LIBC_HAS_SANITIZER) |
