summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c35539e)
raw | patch | inline | side by side (parent: c35539e)
author | Junio C Hamano <gitster@pobox.com> | |
Wed, 20 Aug 2008 19:29:27 +0000 (12:29 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 20 Aug 2008 20:29:30 +0000 (13:29 -0700) |
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 <gitster@pobox.com>
git-for-each-ref for its %(body) element accessed a NULL pointer.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-for-each-ref.c | patch | blob | history | |
t/t6300-for-each-ref.sh | patch | blob | history |
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 445039e19c75e4c9321f7ee64289ef8201a25c14..4d25ec51d009bf18f95c60ca9ccd641ac5792db6 100644 (file)
--- 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;
index a3c8941c726d77fd993a3cfcd7fde4e9aa43da74..8ced59321ef69b6ea2fe3a011f900affea83336e 100755 (executable)
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
"
done
+test_expect_success 'an unusual tag with an incomplete line' '
+
+ git tag -m "bogo" bogo &&
+ bogo=$(git cat-file tag bogo) &&
+ bogo=$(printf "%s" "$bogo" | git mktag) &&
+ git tag -f bogo "$bogo" &&
+ git for-each-ref --format "%(body)" refs/tags/bogo
+
+'
+
test_done