mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +00:00
LibC: strtok_r() should not go past the last token
When we hit the last token, make the saved pointer point to the null terminator instead of to the next token. This ensures that the next call to strtok_r() returns null as expected. Found by running GCC in UE. :^)
This commit is contained in:
parent
a65e7db533
commit
f568aed2e7
1 changed files with 5 additions and 1 deletions
|
@ -457,7 +457,11 @@ char* strtok_r(char* str, const char* delim, char** saved_str)
|
|||
return &str[token_start];
|
||||
}
|
||||
|
||||
*saved_str = &str[token_end + 1];
|
||||
if (str[token_end] == '\0')
|
||||
*saved_str = &str[token_end];
|
||||
else
|
||||
*saved_str = &str[token_end + 1];
|
||||
|
||||
str[token_end] = '\0';
|
||||
return &str[token_start];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue