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

Aly ElAshram via libc-commits libc-commits at lists.llvm.org
Fri Feb 7 16:20:15 PST 2025


================
@@ -120,3 +121,8 @@ TEST(LlvmLibcMemChrTest, SignedCharacterFound) {
   // Should find the first character 'c'.
   ASSERT_EQ(actual[0], c);
 }
+
+TEST(LlvmLibcMemChrTest, CrashOnNullPtr) {
+  ASSERT_DEATH([]() { LIBC_NAMESPACE::memchr(nullptr, 1, 1); },
+               WITH_SIGNAL(SIGSEGV));
+}
----------------
AlyElashram wrote:

Also the `ASSERT_DEATH` macro fails on mac & windows builds. Any suggestion on how to test it? Or should I just wrap it in an `TARGET_OS_IS_LINUX` check

@michaelrj-google @nickdesaulniers 

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


More information about the libc-commits mailing list