diff options
| author | Patrick Steinhardt <ps@pks.im> | 2019-07-21 15:08:22 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2019-07-21 15:08:36 +0200 |
| commit | 9fac8b78347b5830bc1068efd804fa25ebc9ec1e (patch) | |
| tree | d2ece78bffbb75d2d23766a82b62650121c8bb5b /src/config_file.c | |
| parent | 28d11b59edea9864f1095ece7a81ab61a8fe52b5 (diff) | |
| download | libgit2-9fac8b78347b5830bc1068efd804fa25ebc9ec1e.tar.gz | |
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.
Diffstat (limited to 'src/config_file.c')
| -rw-r--r-- | src/config_file.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/config_file.c b/src/config_file.c index a15dba0f2..1b674b135 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) |
