Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 89e7604

Browse files
pks-tEdward Thomson
authored and
Edward Thomson
committed
config_cache: check return value of git_config__lookup_entry
Callers of `git_config__cvar` already handle the case where the function returns an error due to a failed configuration variable lookup, but we are actually swallowing errors when calling `git_config__lookup_entry` inside of the function. Fix this by returning early when `git_config__lookup_entry` returns an error. As we call `git_config__lookup_entry` with `no_errors == false` which leads us to call `get_entry` with `GET_NO_MISSING` we will not return early when the lookup fails due to a missing entry. Like this we are still able to set the default value of the cvar and exit successfully.
1 parent 18c4ae7 commit 89e7604

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/config_cache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar)
8686
struct map_data *data = &_cvar_maps[(int)cvar];
8787
git_config_entry *entry;
8888

89-
git_config__lookup_entry(&entry, config, data->cvar_name, false);
89+
if ((error = git_config__lookup_entry(&entry, config, data->cvar_name, false)) < 0)
90+
return error;
9091

9192
if (!entry)
9293
*out = data->default_value;

0 commit comments

Comments
 (0)