From a0ceeefaf490d81e889a12c28f0989c791b86ef1 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Tue, 17 Aug 2021 17:30:21 +0200 Subject: [PATCH] string: fix strtok detecting NUL only after separators --- src/libc/string/strtok.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libc/string/strtok.c b/src/libc/string/strtok.c index 11d81d3..a60f794 100644 --- a/src/libc/string/strtok.c +++ b/src/libc/string/strtok.c @@ -12,7 +12,7 @@ char *strtok(char * restrict new_s, char const * restrict separators) /* Skip non-delimiters */ char *token = s; s += strcspn(s, separators); - *s++ = 0; + if(*s) *s++ = 0; return token; }