Skip to content

Commit 9c54831

Browse files
this time
1 parent d42c9ab commit 9c54831

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

code/logic/json.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ fossil_media_json_parse_file(const char *filename, fossil_media_json_error_t *er
749749
fclose(f);
750750

751751
fossil_media_json_value_t *v = fossil_media_json_parse(buf, err_out);
752-
free(buf);
752+
fm_free(buf);
753753
return v;
754754
}
755755

@@ -767,7 +767,7 @@ int fossil_media_json_write_file(const fossil_media_json_value_t *v,
767767
return -1;
768768
}
769769
fputs(s, f);
770-
free(s);
770+
fm_free(s);
771771
fclose(f);
772772
return 0;
773773
}
@@ -845,7 +845,8 @@ fossil_media_json_get_path(const fossil_media_json_value_t *root, const char *pa
845845
char *tokenized = fossil_media_strdup(path);
846846
if (!tokenized) return NULL;
847847

848-
char *tok = strtok(tokenized, ".");
848+
char *saveptr = NULL;
849+
char *tok = strtok_r(tokenized, ".", &saveptr);
849850
while (tok && cur) {
850851
if (cur->type == FOSSIL_MEDIA_JSON_OBJECT) {
851852
cur = fossil_media_json_object_get(cur, tok);
@@ -855,15 +856,15 @@ fossil_media_json_get_path(const fossil_media_json_value_t *root, const char *pa
855856
if (*end == '\0') {
856857
cur = fossil_media_json_array_get(cur, (size_t)idx);
857858
} else {
858-
free(tokenized);
859+
fm_free(tokenized);
859860
return NULL;
860861
}
861862
} else {
862-
free(tokenized);
863+
fm_free(tokenized);
863864
return NULL;
864865
}
865-
tok = strtok(NULL, ".");
866+
tok = strtok_r(NULL, ".", &saveptr);
866867
}
867-
free(tokenized);
868+
fm_free(tokenized);
868869
return (fossil_media_json_value_t *)cur;
869870
}

0 commit comments

Comments
 (0)