use get_commit_buffer everywhere
Each of these sites assumes that commit->buffer is valid. Since they would segfault if this was not the case, they are likely to be correct in practice. However, we can future-proof them by using get_commit_buffer. And as a side effect, we abstract away the final bare uses of commit->buffer. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
b66103c3ba
commit
bc6b8fc130
@ -230,12 +230,14 @@ static void add_branch_desc(struct strbuf *out, const char *name)
|
||||
static void record_person(int which, struct string_list *people,
|
||||
struct commit *commit)
|
||||
{
|
||||
const char *buffer;
|
||||
char *name_buf, *name, *name_end;
|
||||
struct string_list_item *elem;
|
||||
const char *field;
|
||||
|
||||
field = (which == 'a') ? "\nauthor " : "\ncommitter ";
|
||||
name = strstr(commit->buffer, field);
|
||||
buffer = get_commit_buffer(commit);
|
||||
name = strstr(buffer, field);
|
||||
if (!name)
|
||||
return;
|
||||
name += strlen(field);
|
||||
@ -247,6 +249,7 @@ static void record_person(int which, struct string_list *people,
|
||||
if (name_end < name)
|
||||
return;
|
||||
name_buf = xmemdupz(name, name_end - name + 1);
|
||||
unuse_commit_buffer(commit, buffer);
|
||||
|
||||
elem = string_list_lookup(people, name_buf);
|
||||
if (!elem) {
|
||||
|
Reference in New Issue
Block a user