Skip to content

Commit

Permalink
Merge branch 'jc/plug-fmt-merge-msg-leak'
Browse files Browse the repository at this point in the history
* jc/plug-fmt-merge-msg-leak:
  fmt-merge-msg: plug small leak of commit buffer
Junio C Hamano committed May 11, 2015
2 parents eb10a85 + 1154aa4 commit 789e98d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions builtin/fmt-merge-msg.c
Original file line number Diff line number Diff line change
@@ -223,16 +223,14 @@ static void add_branch_desc(struct strbuf *out, const char *name)

#define util_as_integral(elem) ((intptr_t)((elem)->util))

static void record_person(int which, struct string_list *people,
struct commit *commit)
static void record_person_from_buf(int which, struct string_list *people,
const char *buffer)
{
const char *buffer;
char *name_buf, *name, *name_end;
struct string_list_item *elem;
const char *field;

field = (which == 'a') ? "\nauthor " : "\ncommitter ";
buffer = get_commit_buffer(commit, NULL);
name = strstr(buffer, field);
if (!name)
return;
@@ -245,7 +243,6 @@ 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) {
@@ -256,6 +253,15 @@ static void record_person(int which, struct string_list *people,
free(name_buf);
}


static void record_person(int which, struct string_list *people,
struct commit *commit)
{
const char *buffer = get_commit_buffer(commit, NULL);
record_person_from_buf(which, people, buffer);
unuse_commit_buffer(commit, buffer);
}

static int cmp_string_list_util_as_integral(const void *a_, const void *b_)
{
const struct string_list_item *a = a_, *b = b_;

0 comments on commit 789e98d

Please sign in to comment.