提交 c8c4450e 编写于 作者: J Jim Meyering 提交者: Junio C Hamano

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: NJim Meyering <meyering@redhat.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 26e08a01
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册