summaryrefslogtreecommitdiff
path: root/fetch-pack.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2019-02-04 00:06:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-02-04 21:33:32 (GMT)
commit23311f35424705f11acf80685bac1fe27e36192f (patch)
tree120db1425a830fad7099a85099c34a1ecfc8784f /fetch-pack.c
parentb5101f929789889c2e536d915698f58d5c5c6b7a (diff)
downloadgit-23311f35424705f11acf80685bac1fe27e36192f.zip
git-23311f35424705f11acf80685bac1fe27e36192f.tar.gz
git-23311f35424705f11acf80685bac1fe27e36192f.tar.bz2
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>
Diffstat (limited to 'fetch-pack.c')
-rw-r--r--fetch-pack.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index 577faa6..2d76287 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1489,6 +1489,7 @@ static void update_shallow(struct fetch_pack_args *args,
rollback_lock_file(&shallow_lock);
} else
commit_lock_file(&shallow_lock);
+ alternate_shallow_file = NULL;
return;
}
@@ -1512,6 +1513,7 @@ static void update_shallow(struct fetch_pack_args *args,
&alternate_shallow_file,
&extra);
commit_lock_file(&shallow_lock);
+ alternate_shallow_file = NULL;
}
oid_array_clear(&extra);
return;
@@ -1551,6 +1553,7 @@ static void update_shallow(struct fetch_pack_args *args,
commit_lock_file(&shallow_lock);
oid_array_clear(&extra);
oid_array_clear(&ref);
+ alternate_shallow_file = NULL;
return;
}