Skip to content

Commit

Permalink
pretty.c: make git_pretty_formats_config return -1 on git_config_stri…
Browse files Browse the repository at this point in the history
…ng failure

`git_pretty_formats_config()` continues without checking git_config_string's
return value which can lead to a SEGFAULT. Instead return -1 when
git_config_string fails signalling `git_config()` to die printing the location
of the erroneous variable.

Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Tanay Abhra authored and Junio C Hamano committed Aug 4, 2014
1 parent d31f3ad commit a26bc61
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ static int git_pretty_formats_config(const char *var, const char *value, void *c

commit_format->name = xstrdup(name);
commit_format->format = CMIT_FMT_USERFORMAT;
git_config_string(&fmt, var, value);
if (git_config_string(&fmt, var, value))
return -1;

if (starts_with(fmt, "format:") || starts_with(fmt, "tformat:")) {
commit_format->is_tformat = fmt[0] == 't';
fmt = strchr(fmt, ':') + 1;
Expand Down

0 comments on commit a26bc61

Please sign in to comment.