pretty.c: make git_pretty_formats_config return -1 on git_config_string 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>

Tanay Abhra committed Aug 4, 2014 at 07:41 UTC a26bc613a64ac2c7ee69a50675e61b004a26382d
1 file changed +3 -1
pretty.c
+3 -1
@@ -66,7 +66,9 @@ static int git_pretty_formats_config(const char *var, const char *value, void *c
66
67 commit_format->name = xstrdup(name);
68 commit_format->format = CMIT_FMT_USERFORMAT;
69 - git_config_string(&fmt, var, value);
69 + if (git_config_string(&fmt, var, value))
70 + return -1;
71 +
72 if (starts_with(fmt, "format:") || starts_with(fmt, "tformat:")) {
73 commit_format->is_tformat = fmt[0] == 't';
74 fmt = strchr(fmt, ':') + 1;