From f1d6c68d8ca3c1dde49354c514e47396904e94e3 Mon Sep 17 00:00:00 2001 From: Mathieu Serandour Date: Thu, 3 Mar 2022 12:07:56 +0100 Subject: [PATCH] fixed strtok bug --- kernel/lib/string.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/lib/string.c b/kernel/lib/string.c index 1044d96..64387a6 100644 --- a/kernel/lib/string.c +++ b/kernel/lib/string.c @@ -300,7 +300,11 @@ char* strtok_r(char* restrict str, const char* restrict delim, char** restrict s if(!next) { *saveptr = NULL; - return ptr; + + if(! *ptr) // reached the end + return NULL; + else + return ptr; } else if(next == ptr) { ptr++;