Skip to content

Commit 23311f3

Browse files
bk2204gitster
authored andcommitted
fetch-pack: clear alternate shallow when complete
When we write an alternate shallow file in update_shallow, we write it into the lock file. The string stored in alternate_shallow_file is copied from the lock file path, but it is freed the moment that the lock file is closed, since we call strbuf_release to free that path. This used to work, since we did not invoke git index-pack more than once, but now that we do, we reuse the freed memory. Ensure we reset the value to NULL to avoid using freed memory. git index-pack will read the repository's shallow file, which will have been updated with the correct information. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b5101f9 commit 23311f3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fetch-pack.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,7 @@ static void update_shallow(struct fetch_pack_args *args,
14891489
rollback_lock_file(&shallow_lock);
14901490
} else
14911491
commit_lock_file(&shallow_lock);
1492+
alternate_shallow_file = NULL;
14921493
return;
14931494
}
14941495

@@ -1512,6 +1513,7 @@ static void update_shallow(struct fetch_pack_args *args,
15121513
&alternate_shallow_file,
15131514
&extra);
15141515
commit_lock_file(&shallow_lock);
1516+
alternate_shallow_file = NULL;
15151517
}
15161518
oid_array_clear(&extra);
15171519
return;
@@ -1551,6 +1553,7 @@ static void update_shallow(struct fetch_pack_args *args,
15511553
commit_lock_file(&shallow_lock);
15521554
oid_array_clear(&extra);
15531555
oid_array_clear(&ref);
1556+
alternate_shallow_file = NULL;
15541557
return;
15551558
}
15561559

0 commit comments

Comments
 (0)