summaryrefslogtreecommitdiff
path: root/builtin/commit.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/commit.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/commit.c')
-rw-r--r--builtin/commit.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 6c95fa76d8..1a0e5f14a3 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -946,24 +946,14 @@ static void handle_untracked_files_arg(struct wt_status *s)
static const char *read_commit_message(const char *name)
{
- const char *out_enc, *out;
+ const char *out_enc;
struct commit *commit;
commit = lookup_commit_reference_by_name(name);
if (!commit)
die(_("could not lookup commit %s"), name);
out_enc = get_commit_output_encoding();
- out = logmsg_reencode(commit, out_enc);
-
- /*
- * If we failed to reencode the buffer, just copy it
- * byte for byte so the user can try to fix it up.
- * This also handles the case where input and output
- * encodings are identical.
- */
- if (out == NULL)
- out = xstrdup(commit->buffer);
- return out;
+ return logmsg_reencode(commit, out_enc);
}
static int parse_and_validate_options(int argc, const char *argv[],