config_file: do not refresh read-only backends If calling `config_refresh` on a read-only configuration file backend, then we will segfault when comparing the timestamp of the file due to `path` being uninitialized. As a read-only snapshot should not be refreshed anyway and stay consistent, we can simply return early when calling `config_refresh` on a read-only snapshot.
diff --git a/src/config_file.c b/src/config_file.c
index a15dba0..1b674b1 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -231,8 +231,10 @@ static int config_refresh(git_config_backend *cfg)
git_config_entries *entries = NULL;
int error, modified;
- error = config_is_modified(&modified, &b->file);
- if (error < 0 && error != GIT_ENOTFOUND)
+ if (cfg->readonly)
+ return 0;
+
+ if ((error = config_is_modified(&modified, &b->file)) < 0 && error != GIT_ENOTFOUND)
goto out;
if (!modified)