Skip to content

Commit 660b373

Browse files
pcloudsgitster
authored andcommitted
pack-objects: don't check size when the object is bad
sha1_object_info() in check_objects() may fail to locate an object in the pack and return type OBJ_BAD. In that case, it will likely leave the "size" field untouched. We delay error handling until later in prepare_pack() though. Until then, do not touch "size" field. This field should contain the default value zero, but we can't say sha1_object_info() cannot damage it. This becomes more important later when the object size may have to be retrieved back from the (non-existing) pack. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0cb3c14 commit 660b373

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin/pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ static void get_object_details(void)
17421742
for (i = 0; i < to_pack.nr_objects; i++) {
17431743
struct object_entry *entry = sorted_by_offset[i];
17441744
check_object(entry);
1745-
if (big_file_threshold < entry->size)
1745+
if (entry->type_valid && big_file_threshold < entry->size)
17461746
entry->no_try_delta = 1;
17471747
}
17481748

@@ -2453,7 +2453,7 @@ static void prepare_pack(int window, int depth)
24532453
*/
24542454
continue;
24552455

2456-
if (entry->size < 50)
2456+
if (!entry->type_valid || entry->size < 50)
24572457
continue;
24582458

24592459
if (entry->no_try_delta)

0 commit comments

Comments
 (0)