From e276c26b4b65711c27e3ef37e732d41eeae42094 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 20 Aug 2008 12:29:27 -0700 Subject: for-each-ref: cope with tags with incomplete lines If you have a tag with a single, incomplete line as its payload, asking git-for-each-ref for its %(body) element accessed a NULL pointer. Signed-off-by: Junio C Hamano --- builtin-for-each-ref.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'builtin-for-each-ref.c') diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c index 445039e19..4d25ec51d 100644 --- a/builtin-for-each-ref.c +++ b/builtin-for-each-ref.c @@ -459,8 +459,10 @@ static void find_subpos(const char *buf, unsigned long sz, const char **sub, con return; *sub = buf; /* first non-empty line */ buf = strchr(buf, '\n'); - if (!buf) + if (!buf) { + *body = ""; return; /* no body */ + } while (*buf == '\n') buf++; /* skip blank between subject and body */ *body = buf; -- cgit v1.2.1