Skip to content

Commit

Permalink
diff.c: guard config parser from value=NULL
Browse files Browse the repository at this point in the history
diff.external, diff.*.command, diff.color.*, color.diff.* and
diff.*.funcname configuration variables expect a string value.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Feb 11, 2008
1 parent a7269e5 commit 64f30e9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,20 @@ int git_diff_ui_config(const char *var, const char *value)
return 0;
}
if (!strcmp(var, "diff.external")) {
if (!value)
return config_error_nonbool(var);
external_diff_cmd_cfg = xstrdup(value);
return 0;
}
if (!prefixcmp(var, "diff.")) {
const char *ep = strrchr(var, '.');

if (ep != var + 4) {
if (!strcmp(ep, ".command"))
if (!strcmp(ep, ".command")) {
if (!value)
return config_error_nonbool(var);
return parse_lldiff_command(var, ep, value);
}
}
}

Expand All @@ -177,15 +182,20 @@ int git_diff_basic_config(const char *var, const char *value)
{
if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
int slot = parse_diff_color_slot(var, 11);
if (!value)
return config_error_nonbool(var);
color_parse(value, var, diff_colors[slot]);
return 0;
}

if (!prefixcmp(var, "diff.")) {
const char *ep = strrchr(var, '.');
if (ep != var + 4) {
if (!strcmp(ep, ".funcname"))
if (!strcmp(ep, ".funcname")) {
if (!value)
return config_error_nonbool(var);
return parse_funcname_pattern(var, ep, value);
}
}
}

Expand Down

0 comments on commit 64f30e9

Please sign in to comment.