summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-05-28 13:02:40 -0400
committerJakob Kaivo <jkk@ung.org>2024-05-28 13:02:40 -0400
commita69b11fd8974a898a26081950bd4add7c82ea45d (patch)
tree131e8da181a4a64be23a582506c99c0e62f226e9
parent49c142c8d87681bfc979b0f2ad81df2d652bde07 (diff)
handle invalid strtok() behavior
-rw-r--r--src/string/strtok.c5
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 = &current;
/* 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 */
/*