summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cfb8f89)
raw | patch | inline | side by side (parent: cfb8f89)
author | Junio C Hamano <gitster@pobox.com> | |
Fri, 28 Sep 2007 08:46:13 +0000 (01:46 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 30 Sep 2007 06:54:37 +0000 (23:54 -0700) |
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>
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>
connect.c | patch | blob | history | |
transport.c | patch | blob | history |
diff --git a/connect.c b/connect.c
index 8b1e9935a85b639f6c48298d07299f72bceaad29..aee78ff2066bee0cc4ddecdba7454c6dad783e39 100644 (file)
--- a/connect.c
+++ b/connect.c
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;
}
diff --git a/transport.c b/transport.c
index 4f9cddc308de318b5ff36c82c7a7600ec8c6c64d..3475ccaf5cc3d3a2ab8002e397ac8d244b59db40 100644 (file)
--- a/transport.c
+++ b/transport.c
die ("Could not read bundle '%s'.", transport->url);
for (i = 0; i < data->header.references.nr; i++) {
struct ref_list_entry *e = data->header.references.list + i;
- struct ref *ref = alloc_ref(strlen(e->name));
+ struct ref *ref = alloc_ref(strlen(e->name) + 1);
hashcpy(ref->old_sha1, e->sha1);
strcpy(ref->name, e->name);
ref->next = result;