Skip to content

Commit

Permalink
Use strtok_r instead of strtok
Browse files Browse the repository at this point in the history
  • Loading branch information
carlgsmith committed Nov 6, 2024
1 parent 8535df8 commit 44c063e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fcgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ normalise_path(const char *path)
{
GString *normalised = g_string_new(NULL);
char *copy = g_strdup(path);
char *token = strtok((char *)copy, "/");
char *saveptr = NULL;
char *token = strtok_r((char *)copy, "/", &saveptr);
char *last = NULL;
while (token) {
if (strcmp(token, ".") == 0) {
Expand All @@ -209,7 +210,7 @@ normalise_path(const char *path)
g_string_append_printf(normalised, "/%s", token);
}
last = token;
token = strtok(NULL, "/");
token = strtok_r(NULL, "/", &saveptr);
}
free(copy);
if (path[strlen(path) - 1] == '/')
Expand Down

0 comments on commit 44c063e

Please sign in to comment.