diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-05-11 14:23:45 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-05-11 14:23:46 -0700 |
commit | 789e98df82817531260fa8b27dce0b30017cc3a2 (patch) | |
tree | a9422e3af103a3b31472f8abd7cf89a7f4a7cea2 /builtin/fmt-merge-msg.c | |
parent | eb10a850985fff2eb9a6810bc8fa35129f2b3b71 (diff) | |
parent | 1154aa42159383c3339567f6385c21a615c8b93a (diff) | |
download | git-789e98df82817531260fa8b27dce0b30017cc3a2.tar.gz |
Merge branch 'jc/plug-fmt-merge-msg-leak'
* jc/plug-fmt-merge-msg-leak:
fmt-merge-msg: plug small leak of commit buffer
Diffstat (limited to 'builtin/fmt-merge-msg.c')
-rw-r--r-- | builtin/fmt-merge-msg.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c index 1d962dc569..05f4c26311 100644 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@ -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_; |