summaryrefslogtreecommitdiff
path: root/builtin/blame.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-02-04 10:25:18 -0800
committerJunio C Hamano <gitster@pobox.com>2013-02-04 10:25:18 -0800
commitd5365b43274779246665416caf1a51af5a29f776 (patch)
tree4964cb7640ffec8458d3a56815d0d4c21369f1f6 /builtin/blame.c
parent27d46a70724ef5e087863c3db35eb7ca9c084c2c (diff)
parentbe5c9fb9049ed470e7005f159bb923a5f4de1309 (diff)
downloadgit-d5365b43274779246665416caf1a51af5a29f776.tar.gz
Merge branch 'jk/read-commit-buffer-data-after-free'
Clarify the ownership rule for commit->buffer field, which some callers incorrectly accessed without making sure it is populated. * jk/read-commit-buffer-data-after-free: logmsg_reencode: lazily load missing commit buffers logmsg_reencode: never return NULL commit: drop useless xstrdup of commit message
Diffstat (limited to 'builtin/blame.c')
-rw-r--r--builtin/blame.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index b431ba3209..86100e9662 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1420,32 +1420,18 @@ static void get_commit_info(struct commit *commit,
{
int len;
const char *subject, *encoding;
- char *reencoded, *message;
+ char *message;
commit_info_init(ret);
- /*
- * We've operated without save_commit_buffer, so
- * we now need to populate them for output.
- */
- if (!commit->buffer) {
- enum object_type type;
- unsigned long size;
- commit->buffer =
- read_sha1_file(commit->object.sha1, &type, &size);
- if (!commit->buffer)
- die("Cannot read commit %s",
- sha1_to_hex(commit->object.sha1));
- }
encoding = get_log_output_encoding();
- reencoded = logmsg_reencode(commit, encoding);
- message = reencoded ? reencoded : commit->buffer;
+ message = logmsg_reencode(commit, encoding);
get_ac_line(message, "\nauthor ",
&ret->author, &ret->author_mail,
&ret->author_time, &ret->author_tz);
if (!detailed) {
- free(reencoded);
+ logmsg_free(message, commit);
return;
}
@@ -1459,7 +1445,7 @@ static void get_commit_info(struct commit *commit,
else
strbuf_addf(&ret->summary, "(%s)", sha1_to_hex(commit->object.sha1));
- free(reencoded);
+ logmsg_free(message, commit);
}
/*