diff options
Diffstat (limited to 'libc/src/string/memrchr.cpp')
| -rw-r--r-- | libc/src/string/memrchr.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/src/string/memrchr.cpp b/libc/src/string/memrchr.cpp index d665e225bbb7..d5c843c733b3 100644 --- a/libc/src/string/memrchr.cpp +++ b/libc/src/string/memrchr.cpp @@ -9,11 +9,16 @@ #include "src/string/memrchr.h" #include "src/__support/common.h" #include "src/__support/macros/config.h" +#include "src/__support/macros/null_check.h" #include <stddef.h> namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(void *, memrchr, (const void *src, int c, size_t n)) { + + if (n) + LIBC_CRASH_ON_NULLPTR(src); + const unsigned char *str = reinterpret_cast<const unsigned char *>(src); const unsigned char ch = static_cast<unsigned char>(c); for (; n != 0; --n) { |
