summaryrefslogtreecommitdiff
path: root/connect.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-09-28 01:46:13 -0700
committerJunio C Hamano <gitster@pobox.com>2007-09-29 23:54:37 -0700
commit90446a0009d9c9c0a06c512f0836e0d30f78d2d0 (patch)
treef189f0e00b6626f9342d12d4ae9f9e0269b7dc0f /connect.c
parentcfb8f898a883e2fb2fd5ecec0fe83662b64f1373 (diff)
downloadgit-90446a0009d9c9c0a06c512f0836e0d30f78d2d0.tar.gz
bundle transport: fix an alloc_ref() call
Currently alloc_ref() expects the length of the refname plus 1 as its parameter, prepares that much space and returns a "ref" structure for the caller to fill the refname. One caller in transport.c::get_refs_from_bundle() however allocated one byte less. It may be a good idea to change the calling convention to give alloc_ref() the length of the refname, but that clean-up can be done in a separate patch. This patch only fixes the bug and makes all callers consistent. There was also one overallocation in connect.c, which would not hurt but was wasteful. This patch fixes it as well. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'connect.c')
-rw-r--r--connect.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/connect.c b/connect.c
index 8b1e9935a8..aee78ff206 100644
--- a/connect.c
+++ b/connect.c
@@ -72,9 +72,9 @@ struct ref **get_remote_heads(int in, struct ref **list,
continue;
if (nr_match && !path_match(name, nr_match, match))
continue;
- ref = alloc_ref(len - 40);
+ ref = alloc_ref(name_len + 1);
hashcpy(ref->old_sha1, old_sha1);
- memcpy(ref->name, buffer + 41, len - 40);
+ memcpy(ref->name, buffer + 41, name_len + 1);
*list = ref;
list = &ref->next;
}