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
This commit is contained in:
@ -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[],
|
||||
|
Reference in New Issue
Block a user