Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-04-30 14:15:45 +0400
committerRussell Belfer <rb@github.com>2013-04-30 14:15:45 +0400
commit0a1755c045b930de474883eb6e7fedcc3403b494 (patch)
treecf129ba2df0a75873edc84579f72ea29044747de /src/config.c
parent4157851076d476b3b7f9a8bb9b85497517b14cdf (diff)
Catch issue in config set with no config file
This prevents a segfault when setting a value in the config of a repository that doesn't have a config file.
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 3c0bbe9a7..2e1268ef3 100644
--- a/src/config.c
+++ b/src/config.c
@@ -373,6 +373,12 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value)
}
internal = git_vector_get(&cfg->files, 0);
+ if (!internal) {
+ /* Should we auto-vivify .git/config? Tricky from this location */
+ giterr_set(GITERR_CONFIG, "Cannot set value when no config files exist");
+ return GIT_ENOTFOUND;
+ }
+
file = internal->file;
error = file->set(file, name, value);