-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
After a call to `strtok`, the internal state is left to \0; this leads to returning NULL on the next call regardless of the string. Signed-off-by: Daniele Ahmed <ahmeddan amazon c;0m >
- Loading branch information
Showing
1 changed file
with
1 addition
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,7 +292,7 @@ static inline char *strtok(char *s, const char *delim) { | |
int ch; | ||
|
||
if (NULL == s) | ||
s = lasts; | ||
s = lasts + 1; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
82marbag
Author
Contributor
|
||
|
||
do { | ||
if ((ch = *s++) == '\0') | ||
|
If s is NULL first time strtok is called then it would be returning 1.
Sidenote: lasts should be initialized to NULL (I think compiler would ensure that but doing explicit assignment doesn't hurt)