Skip to content

Commit 9fac8b7

Browse files
committed
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.
1 parent 28d11b5 commit 9fac8b7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/config_file.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,10 @@ static int config_refresh(git_config_backend *cfg)
231231
git_config_entries *entries = NULL;
232232
int error, modified;
233233

234-
error = config_is_modified(&modified, &b->file);
235-
if (error < 0 && error != GIT_ENOTFOUND)
234+
if (cfg->readonly)
235+
return 0;
236+
237+
if ((error = config_is_modified(&modified, &b->file)) < 0 && error != GIT_ENOTFOUND)
236238
goto out;
237239

238240
if (!modified)

0 commit comments

Comments
 (0)