commit 00fd4513a6cd6195655aec7297c974acb835d4a3
parent 37b38dadd77079cd7e537f247dcb0a45301e539b
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Mon, 18 Dec 2023 13:50:01 +0000
and one more
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git 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 ;
}