summaryrefslogtreecommitdiff
path: root/libc/test/src/string/stpncpy_test.cpp
diff options
context:
space:
mode:
authorAmir Ayupov <aaupov@fb.com>2025-06-08 17:43:02 -0700
committerAmir Ayupov <aaupov@fb.com>2025-06-08 17:43:02 -0700
commit68b99df7ad1b910378c8cda5afff637fbe3c0efc (patch)
tree1d2e51419c3f89a0909603d355598c27f1a92d42 /libc/test/src/string/stpncpy_test.cpp
parentbbbecc425389aeb7b93d9018b40a95b389c27f40 (diff)
parentc480dcddd91e3ff0707d6629e6ddac8587d9d1f1 (diff)
[𝘀𝗽𝗿] changes introduced through rebaseusers/aaupov/spr/main.bolt-sort-entrydata
Created using spr 1.3.4 [skip ci]
Diffstat (limited to 'libc/test/src/string/stpncpy_test.cpp')
-rw-r--r--libc/test/src/string/stpncpy_test.cpp10
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)