} else if (!strcmp(value, "*")) {
data->is_safe = 1;
} else {
- char *interpolated = NULL;
-
- if (!git_config_pathname(&interpolated, key, value) &&
- !fspathcmp(data->path, interpolated ? interpolated : value))
- data->is_safe = 1;
-
- free(interpolated);
- const char *allowed = NULL;
++ char *allowed = NULL;
+
+ if (!git_config_pathname(&allowed, key, value)) {
- if (!allowed)
- allowed = value;
- if (ends_with(allowed, "/*")) {
- size_t len = strlen(allowed);
- if (!fspathncmp(allowed, data->path, len - 1))
++ const char *check = allowed ? allowed : value;
++ if (ends_with(check, "/*")) {
++ size_t len = strlen(check);
++ if (!fspathncmp(check, data->path, len - 1))
+ data->is_safe = 1;
- } else if (!fspathcmp(data->path, allowed)) {
++ } else if (!fspathcmp(data->path, check)) {
+ data->is_safe = 1;
+ }
+ }
+ if (allowed != value)
- free((char *)allowed);
++ free(allowed);
}
return 0;