From 00fd4513a6cd6195655aec7297c974acb835d4a3 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 18 Dec 2023 13:50:01 +0000 Subject: and one more Signed-off-by: Laurent Bercot --- src/libstddjb/byte_chr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 ; } -- cgit v1.2.3