[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:16 PST 2025


================
@@ -9,12 +9,15 @@
 #include "src/string/strsep.h"
 
 #include "src/__support/macros/config.h"
+#include "src/__support/macros/null_check.h"
 #include "src/string/string_utils.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(char *, strsep,
                    (char **__restrict stringp, const char *__restrict delim)) {
+  LIBC_CRASH_ON_NULLPTR(stringp);
+  LIBC_CRASH_ON_NULLPTR(delim);
----------------
AlyElashram wrote:

hmm , but what if the `stringp` is a nullpointer in of itself. That would still be UB no? Deref-ing a nullptr would still be UB, that's why I'm checking for it before the actual null check.

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


More information about the libc-commits mailing list