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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Feb 4, 2019 at 00:06 UTC
23311f35424705f11acf80685bac1fe27e36192f
1 file changed
+3
fetch-pack.c
+3
@@ -1489,6 +1489,7 @@ static void update_shallow(struct fetch_pack_args *args,
1489
rollback_lock_file(&shallow_lock);
1490
} else
1491
commit_lock_file(&shallow_lock);
1492
+ alternate_shallow_file = NULL;
1493
return;
1494
}
1495
@@ -1512,6 +1513,7 @@ static void update_shallow(struct fetch_pack_args *args,
1513
&alternate_shallow_file,
1514
&extra);
1515
commit_lock_file(&shallow_lock);
1516
+ alternate_shallow_file = NULL;
1517
}
1518
oid_array_clear(&extra);
1519
return;
@@ -1551,6 +1553,7 @@ static void update_shallow(struct fetch_pack_args *args,
1553
commit_lock_file(&shallow_lock);
1554
oid_array_clear(&extra);
1555
oid_array_clear(&ref);
1556
+ alternate_shallow_file = NULL;
1557
return;
1558
}
1559