From: Tanay Abhra Date: Mon, 4 Aug 2014 14:41:15 +0000 (-0700) Subject: pretty.c: make git_pretty_formats_config return -1 on git_config_string failure X-Git-Tag: v2.2.0-rc0~174^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a26bc613a64ac2c7ee69a50675e61b004a26382d;p=git 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 Reviewed-by: Matthieu Moy Signed-off-by: Junio C Hamano --- diff --git a/pretty.c b/pretty.c index f64ff9a10c..d3c2224de6 100644 --- a/pretty.c +++ b/pretty.c @@ -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;