Skip to content

Commit 1d2bef9

Browse files
committed
Merge branch 'gc/bare-repo-discovery' into next
Fix-up for what has been merged to 'master' recently. * gc/bare-repo-discovery: config.c: NULL check when reading protected config
2 parents b063444 + 776f184 commit 1d2bef9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

config.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,8 @@ int git_config_from_file_with_options(config_fn_t fn, const char *filename,
19791979
int ret = -1;
19801980
FILE *f;
19811981

1982+
if (!filename)
1983+
BUG("filename cannot be NULL");
19821984
f = fopen_or_warn(filename, "r");
19831985
if (f) {
19841986
ret = do_config_from_file(fn, CONFIG_ORIGIN_FILE, filename,
@@ -2645,9 +2647,12 @@ static void read_protected_config(void)
26452647
system_config = git_system_config();
26462648
git_global_config(&user_config, &xdg_config);
26472649

2648-
git_configset_add_file(&protected_config, system_config);
2649-
git_configset_add_file(&protected_config, xdg_config);
2650-
git_configset_add_file(&protected_config, user_config);
2650+
if (system_config)
2651+
git_configset_add_file(&protected_config, system_config);
2652+
if (xdg_config)
2653+
git_configset_add_file(&protected_config, xdg_config);
2654+
if (user_config)
2655+
git_configset_add_file(&protected_config, user_config);
26512656
git_configset_add_parameters(&protected_config);
26522657

26532658
free(system_config);

0 commit comments

Comments
 (0)