diff options
author | Jeff King <peff@peff.net> | 2012-05-21 19:09:51 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-05-22 09:07:52 -0700 |
commit | e21ab1340a1a22f017e9c3e4fc0deb9f4de36917 (patch) | |
tree | 79aa205abb447741af4347d2da97db7b9b2153f4 | |
parent | http-push: do not access git_default_email directly (diff) | |
download | tgif-e21ab1340a1a22f017e9c3e4fc0deb9f4de36917.tar.xz |
fmt-merge-msg: don't use static buffer in record_person
The record_person function just parses out the "name" field
of the person line in a commit and adds it to a string_list.
The only reason we need an extra buffer is that the
string_list functions require a NUL-terminated string.
Instead of the static buffer, we can just allocate a
temporary NUL-terminated copy. In addition to removing a
useless limit, this removes the only user of MAX_GITNAME
outside of ident.c.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/fmt-merge-msg.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c index a517f1794a..4ee6a88d75 100644 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@ -230,7 +230,7 @@ static void add_branch_desc(struct strbuf *out, const char *name) static void record_person(int which, struct string_list *people, struct commit *commit) { - char name_buf[MAX_GITNAME], *name, *name_end; + char *name_buf, *name, *name_end; struct string_list_item *elem; const char *field = (which == 'a') ? "\nauthor " : "\ncommitter "; @@ -243,10 +243,9 @@ static void record_person(int which, struct string_list *people, name_end--; while (isspace(*name_end) && name <= name_end) name_end--; - if (name_end < name || name + MAX_GITNAME <= name_end) + if (name_end < name) return; - memcpy(name_buf, name, name_end - name + 1); - name_buf[name_end - name + 1] = '\0'; + name_buf = xmemdupz(name, name_end - name + 1); elem = string_list_lookup(people, name_buf); if (!elem) { @@ -254,6 +253,7 @@ static void record_person(int which, struct string_list *people, elem->util = (void *)0; } elem->util = (void*)(util_as_integral(elem) + 1); + free(name_buf); } static int cmp_string_list_util_as_integral(const void *a_, const void *b_) |