summaryrefslogtreecommitdiff
path: root/src/config_file.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-07-21 15:08:22 +0200
committerPatrick Steinhardt <ps@pks.im>2019-07-21 15:08:36 +0200
commit9fac8b78347b5830bc1068efd804fa25ebc9ec1e (patch)
treed2ece78bffbb75d2d23766a82b62650121c8bb5b /src/config_file.c
parent28d11b59edea9864f1095ece7a81ab61a8fe52b5 (diff)
downloadlibgit2-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.c6
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)