diff options
author | Russell Belfer <rb@github.com> | 2013-04-30 14:15:45 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-04-30 14:15:45 +0400 |
commit | 0a1755c045b930de474883eb6e7fedcc3403b494 (patch) | |
tree | cf129ba2df0a75873edc84579f72ea29044747de /src/config.c | |
parent | 4157851076d476b3b7f9a8bb9b85497517b14cdf (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.c | 6 |
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); |