summaryrefslogtreecommitdiff
path: root/libc/src/string/memccpy.cpp
diff options
context:
space:
mode:
authorAly ElAshram <71949028+AlyElashram@users.noreply.github.com>2025-06-04 20:08:27 +0300
committerGitHub <noreply@github.com>2025-06-04 13:08:27 -0400
commitff844df719d7226a46b8cb0d99aef9480cced247 (patch)
treeec4fdf604da96f6b652f4d44769383caa06ad884 /libc/src/string/memccpy.cpp
parentec5610c4a2ef15551fdfbe9c990851376f58efb6 (diff)
[libc] Expand usage of libc null checks. (#116262)
Fixes #111546 --------- Co-authored-by: alyyelashram <150528548+alyyelashram@users.noreply.github.com>
Diffstat (limited to 'libc/src/string/memccpy.cpp')
-rw-r--r--libc/src/string/memccpy.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/src/string/memccpy.cpp b/libc/src/string/memccpy.cpp
index ae90cf9370d4..d5654fc5e46a 100644
--- a/libc/src/string/memccpy.cpp
+++ b/libc/src/string/memccpy.cpp
@@ -10,6 +10,7 @@
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
+#include "src/__support/macros/null_check.h"
#include <stddef.h> // For size_t.
namespace LIBC_NAMESPACE_DECL {
@@ -17,6 +18,10 @@ namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(void *, memccpy,
(void *__restrict dest, const void *__restrict src, int c,
size_t count)) {
+ if (count) {
+ LIBC_CRASH_ON_NULLPTR(dest);
+ LIBC_CRASH_ON_NULLPTR(src);
+ }
unsigned char end = static_cast<unsigned char>(c);
const unsigned char *uc_src = static_cast<const unsigned char *>(src);
unsigned char *uc_dest = static_cast<unsigned char *>(dest);