From a69b11fd8974a898a26081950bd4add7c82ea45d Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 28 May 2024 13:02:40 -0400 Subject: handle invalid strtok() behavior --- src/string/strtok.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/string/strtok.c b/src/string/strtok.c index c46a9556..b48bba18 100644 --- a/src/string/strtok.c +++ b/src/string/strtok.c @@ -5,12 +5,15 @@ char * strtok(char * restrict s1, const char * restrict s2) { - static char *current = 0; + static char *current = NULL; static char **state = ¤t; /* TODO */ SIGNAL_SAFE(0); ASSERT_NONNULL(s2); + if (current == NULL && s1 == NULL) { + UNDEFINED("strtok() called with NULL input and no previous call"); + } /* nothing is copied, overlap is OK */ /* -- cgit v1.2.1