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>
Junio C Hamano committed
Dec 28, 2006 at 22:29 UTC
9c18df19073bad62e16d6b6b8e1939fd15424612
1 file changed
+5
-2
builtin-pack-objects.c
+5
-2
@@ -1003,6 +1003,7 @@ static void check_object(struct object_entry *entry)
1003
if (!no_reuse_delta) {
1004
unsigned char c, *base_name;
1005
unsigned long ofs;
1006
+ unsigned long used_0;
1007
/* there is at least 20 bytes left in the pack */
1008
switch (entry->in_pack_type) {
1009
case OBJ_REF_DELTA:
@@ -1013,14 +1014,15 @@ static void check_object(struct object_entry *entry)
1014
case OBJ_OFS_DELTA:
1015
buf = use_pack(p, &w_curs,
1016
entry->in_pack_offset + used, NULL);
1016
- c = buf[used++];
1017
+ used_0 = 0;
1018
+ c = buf[used_0++];
1019
ofs = c & 127;
1020
while (c & 128) {
1021
ofs += 1;
1022
if (!ofs || ofs & ~(~0UL >> 7))
1023
die("delta base offset overflow in pack for %s",
1024
sha1_to_hex(entry->sha1));
1023
- c = buf[used++];
1025
+ c = buf[used_0++];
1026
ofs = (ofs << 7) + (c & 127);
1027
}
1028
if (ofs >= entry->in_pack_offset)
@@ -1028,6 +1030,7 @@ static void check_object(struct object_entry *entry)
1030
sha1_to_hex(entry->sha1));
1031
ofs = entry->in_pack_offset - ofs;
1032
base_name = find_packed_object_name(p, ofs);
1033
+ used += used_0;
1034
break;
1035
default:
1036
base_name = NULL;