Skip to content

Commit a26bc61

Browse files
tanayabhgitster
authored andcommitted
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 <[email protected]> Reviewed-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d31f3ad commit a26bc61

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pretty.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ static int git_pretty_formats_config(const char *var, const char *value, void *c
6666

6767
commit_format->name = xstrdup(name);
6868
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+
7072
if (starts_with(fmt, "format:") || starts_with(fmt, "tformat:")) {
7173
commit_format->is_tformat = fmt[0] == 't';
7274
fmt = strchr(fmt, ':') + 1;

0 commit comments

Comments
 (0)