summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-12-18 13:50:01 +0000
committerLaurent Bercot <ska@appnovation.com>2023-12-18 13:50:01 +0000
commit00fd4513a6cd6195655aec7297c974acb835d4a3 (patch)
tree75d2f319b36cb21d39500d9c077e2b9404344b5e
parent37b38dadd77079cd7e537f247dcb0a45301e539b (diff)
downloadskalibs-00fd4513a6cd6195655aec7297c974acb835d4a3.tar.xz
and one more
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--src/libstddjb/byte_chr.c4
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 ;
}