]> git.cameronkatri.com Git - cgit.git/blobdiff - shared.c
ui-shared: fix resource leak: free allocation from cgit_currenturl
[cgit.git] / shared.c
index 3d91a76ec09c8a88aefa2d1148f3542aa6850565..e216c642a4f374c4e7fce922c66c31527eb6b522 100644 (file)
--- a/shared.c
+++ b/shared.c
@@ -563,7 +563,7 @@ char *expand_macros(const char *txt)
 
 char *get_mimetype_for_filename(const char *filename)
 {
-       char *ext, *mimetype, *token, line[1024];
+       char *ext, *mimetype, *token, line[1024], *saveptr;
        FILE *file;
        struct string_list_item *mime;
 
@@ -588,8 +588,8 @@ char *get_mimetype_for_filename(const char *filename)
        while (fgets(line, sizeof(line), file)) {
                if (!line[0] || line[0] == '#')
                        continue;
-               mimetype = strtok(line, " \t\r\n");
-               while ((token = strtok(NULL, " \t\r\n"))) {
+               mimetype = strtok_r(line, " \t\r\n", &saveptr);
+               while ((token = strtok_r(NULL, " \t\r\n", &saveptr))) {
                        if (!strcasecmp(ext, token)) {
                                fclose(file);
                                return xstrdup(mimetype);