diff options
author | Jakob Kaivo <jkk@ung.org> | 2024-05-28 13:02:40 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2024-05-28 13:02:40 -0400 |
commit | a69b11fd8974a898a26081950bd4add7c82ea45d (patch) | |
tree | 131e8da181a4a64be23a582506c99c0e62f226e9 | |
parent | 49c142c8d87681bfc979b0f2ad81df2d652bde07 (diff) |
handle invalid strtok() behavior
-rw-r--r-- | src/string/strtok.c | 5 |
1 files changed, 4 insertions, 1 deletions
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 */ /* |