diff options
author | Junio C Hamano <junkio@cox.net> | 2006-12-28 22:29:06 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-12-29 11:36:45 -0800 |
commit | 9c18df19073bad62e16d6b6b8e1939fd15424612 (patch) | |
tree | 277ef469fef80520dcf8a779eedba28dc9d43479 | |
parent | f5b1b5a07e2d715c5ee7c098e95bd3dbc8ee745d (diff) | |
download | git-9c18df19073bad62e16d6b6b8e1939fd15424612.tar.gz git-9c18df19073bad62e16d6b6b8e1939fd15424612.tar.xz |
pack-objects: fix use of use_pack().
The code calls use_pack() to make that the variably encoded
offset fits in the mmap'ed window, but it forgot that the
operation gives the pointer to the beginning of the asked
region.
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r-- | builtin-pack-objects.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index e9a1804fa..42dd8c87a 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -1003,6 +1003,7 @@ static void check_object(struct object_entry *entry) if (!no_reuse_delta) { unsigned char c, *base_name; unsigned long ofs; + unsigned long used_0; /* there is at least 20 bytes left in the pack */ switch (entry->in_pack_type) { case OBJ_REF_DELTA: @@ -1013,14 +1014,15 @@ static void check_object(struct object_entry *entry) case OBJ_OFS_DELTA: buf = use_pack(p, &w_curs, entry->in_pack_offset + used, NULL); - c = buf[used++]; + used_0 = 0; + c = buf[used_0++]; ofs = c & 127; while (c & 128) { ofs += 1; if (!ofs || ofs & ~(~0UL >> 7)) die("delta base offset overflow in pack for %s", sha1_to_hex(entry->sha1)); - c = buf[used++]; + c = buf[used_0++]; ofs = (ofs << 7) + (c & 127); } if (ofs >= entry->in_pack_offset) @@ -1028,6 +1030,7 @@ static void check_object(struct object_entry *entry) sha1_to_hex(entry->sha1)); ofs = entry->in_pack_offset - ofs; base_name = find_packed_object_name(p, ofs); + used += used_0; break; default: base_name = NULL; |