summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-08-05 22:52:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-08-05 22:52:14 (GMT)
commitac7f41fb8c9fb07adfc1e54f0ec6a7af247c8e23 (patch)
treeb5b134e8252cddf0c7bed3bde9c9725598479cb4
parent4af7188bc97f70277d0f10d56d5373022b1fa385 (diff)
parent776f184893d2861a729aa4b91d69931036e03e4b (diff)
downloadgit-ac7f41fb8c9fb07adfc1e54f0ec6a7af247c8e23.zip
git-ac7f41fb8c9fb07adfc1e54f0ec6a7af247c8e23.tar.gz
git-ac7f41fb8c9fb07adfc1e54f0ec6a7af247c8e23.tar.bz2
Merge branch 'gc/bare-repo-discovery'
Fix-up for what has been merged to 'master' recently. * gc/bare-repo-discovery: config.c: NULL check when reading protected config
-rw-r--r--config.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/config.c b/config.c
index 015bec3..e8ebef7 100644
--- a/config.c
+++ b/config.c
@@ -1979,6 +1979,8 @@ int git_config_from_file_with_options(config_fn_t fn, const char *filename,
int ret = -1;
FILE *f;
+ if (!filename)
+ BUG("filename cannot be NULL");
f = fopen_or_warn(filename, "r");
if (f) {
ret = do_config_from_file(fn, CONFIG_ORIGIN_FILE, filename,
@@ -2645,9 +2647,12 @@ static void read_protected_config(void)
system_config = git_system_config();
git_global_config(&user_config, &xdg_config);
- git_configset_add_file(&protected_config, system_config);
- git_configset_add_file(&protected_config, xdg_config);
- git_configset_add_file(&protected_config, user_config);
+ if (system_config)
+ git_configset_add_file(&protected_config, system_config);
+ if (xdg_config)
+ git_configset_add_file(&protected_config, xdg_config);
+ if (user_config)
+ git_configset_add_file(&protected_config, user_config);
git_configset_add_parameters(&protected_config);
free(system_config);