summaryrefslogtreecommitdiff
path: root/libc/src/string/memcmp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/string/memcmp.cpp')
-rw-r--r--libc/src/string/memcmp.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/src/string/memcmp.cpp b/libc/src/string/memcmp.cpp
index 68996fb78723..d2f67f0478ef 100644
--- a/libc/src/string/memcmp.cpp
+++ b/libc/src/string/memcmp.cpp
@@ -8,6 +8,7 @@
#include "src/string/memcmp.h"
#include "src/__support/macros/config.h"
+#include "src/__support/macros/null_check.h"
#include "src/string/memory_utils/inline_memcmp.h"
#include <stddef.h> // size_t
@@ -16,6 +17,10 @@ namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, memcmp,
(const void *lhs, const void *rhs, size_t count)) {
+ if (count) {
+ LIBC_CRASH_ON_NULLPTR(lhs);
+ LIBC_CRASH_ON_NULLPTR(rhs);
+ }
return inline_memcmp(lhs, rhs, count);
}