@matheusbsbs / matheus-bagliano / commits / d7fb91c69d
Fork 0

git-format-patch: do not crash with format.headers without value.

An incorrect config file can say: [format] headers and crash the parsing. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jan 17, 2007 at 11:13 UTC d7fb91c69dc347c53b0d9830b13fdadf217a78f1
1 file changed +5 -1
builtin-log.c
+5 -1
@@ -202,7 +202,11 @@ static const char *fmt_patch_suffix = ".txt";
202 static int git_format_config(const char *var, const char *value)
203 {
204 if (!strcmp(var, "format.headers")) {
205 - int len = strlen(value);
205 + int len;
206 +
207 + if (!value)
208 + die("format.headers without value");
209 + len = strlen(value);
210 extra_headers_size += len + 1;
211 extra_headers = xrealloc(extra_headers, extra_headers_size);
212 extra_headers[extra_headers_size - len - 1] = 0;