Skip to content

Commit 886ddf4

Browse files
rscharfegitster
authored andcommitted
sha1_file: release fallback base's memory in unpack_entry()
If a pack entry that's used as a delta base is corrupt, unpack_entry() marks it as unusable and then searches the object again in the hope that it can be found in another pack or in a loose file. The memory for this external base object is never released. Free it after use. Signed-off-by: Rene Scharfe <[email protected]> Reviewed-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c3808ca commit 886ddf4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sha1_file.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,6 +2351,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
23512351
while (delta_stack_nr) {
23522352
void *delta_data;
23532353
void *base = data;
2354+
void *external_base = NULL;
23542355
unsigned long delta_size, base_size = size;
23552356
int i;
23562357

@@ -2377,6 +2378,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
23772378
p->pack_name);
23782379
mark_bad_packed_object(p, base_sha1);
23792380
base = read_object(base_sha1, &type, &base_size);
2381+
external_base = base;
23802382
}
23812383
}
23822384

@@ -2395,6 +2397,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
23952397
"at offset %"PRIuMAX" from %s",
23962398
(uintmax_t)curpos, p->pack_name);
23972399
data = NULL;
2400+
free(external_base);
23982401
continue;
23992402
}
24002403

@@ -2414,6 +2417,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
24142417
error("failed to apply delta");
24152418

24162419
free(delta_data);
2420+
free(external_base);
24172421
}
24182422

24192423
*final_type = type;

0 commit comments

Comments
 (0)