[libc-commits] [libc] [libc] Expand usage of libc null checks. (PR #116262)

via libc-commits libc-commits at lists.llvm.org
Wed Jan 8 13:31:05 PST 2025


================
@@ -83,3 +84,12 @@ TEST(LlvmLibcStrSpnTest, DuplicatedCharactersToBeSearchedForShouldStillMatch) {
   EXPECT_EQ(LIBC_NAMESPACE::strspn("aaa", "aa"), size_t{3});
   EXPECT_EQ(LIBC_NAMESPACE::strspn("aaaa", "aa"), size_t{4});
 }
+
+#if defined(LIBC_TARGET_OS_IS_LINUX)
+
+TEST(LlvmLibcStrSpnTest, CrashOnNullPtr) {
+  ASSERT_DEATH([]() { LIBC_NAMESPACE::strspn(nullptr, nullptr); },
+               WITH_SIGNAL(SIGSEGV));
+}
+
+#endif // defined(LIBC_TARGET_OS_IS_LINUX)
----------------
lntue wrote:

nit: missing extra line at the end.

https://github.com/llvm/llvm-project/pull/116262


More information about the libc-commits mailing list