diff options
-rw-r--r-- | src/libstddjb/byte_chr.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libstddjb/byte_chr.c b/src/libstddjb/byte_chr.c index ba774aa..8203433 100644 --- a/src/libstddjb/byte_chr.c +++ b/src/libstddjb/byte_chr.c @@ -5,6 +5,8 @@ size_t byte_chr (char const *s, size_t n, int c) { - void *p = memchr(s, c, n) ; + void *p ; + if (!n) return 0 ; + p = memchr(s, c, n) ; return p ? (char *)p - s : n ; } |