From: Jim Meyering Date: Tue, 19 Aug 2008 18:42:04 +0000 (+0200) Subject: git format-patch: avoid underrun when format.headers is empty or all NLs X-Git-Tag: v1.6.0.1~24 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c8c4450e1949055cb57e32425b125f45f3481742;p=git.git git format-patch: avoid underrun when format.headers is empty or all NLs * builtin-log.c (add_header): Avoid a buffer underrun when format.headers is empty or all newlines. Reproduce with this: git config format.headers '' && git format-patch -1 Signed-off-by: Jim Meyering Signed-off-by: Junio C Hamano --- diff --git a/builtin-log.c b/builtin-log.c index f4975cf35..911fd6599 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -461,7 +461,7 @@ static int extra_cc_alloc; static void add_header(const char *value) { int len = strlen(value); - while (value[len - 1] == '\n') + while (len && value[len - 1] == '\n') len--; if (!strncasecmp(value, "to: ", 4)) { ALLOC_GROW(extra_to, extra_to_nr + 1, extra_to_alloc);