aboutsummaryrefslogtreecommitdiffstats
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fetch-pack.c14
-rw-r--r--builtin/fetch.c1
-rw-r--r--builtin/push.c1
-rw-r--r--builtin/send-pack.c2
4 files changed, 17 insertions, 1 deletions
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 49222a36fa..62e8c3aa6b 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -53,6 +53,7 @@ int cmd_fetch_pack(int argc,
struct ref *fetched_refs = NULL, *remote_refs = NULL;
const char *dest = NULL;
struct ref **sought = NULL;
+ struct ref **sought_to_free = NULL;
int nr_sought = 0, alloc_sought = 0;
int fd[2];
struct string_list pack_lockfiles = STRING_LIST_INIT_DUP;
@@ -243,6 +244,13 @@ int cmd_fetch_pack(int argc,
BUG("unknown protocol version");
}
+ /*
+ * Create a shallow copy of `sought` so that we can free all of its entries.
+ * This is because `fetch_pack()` will modify the array to evict some
+ * entries, but won't free those.
+ */
+ DUP_ARRAY(sought_to_free, sought, nr_sought);
+
fetched_refs = fetch_pack(&args, fd, remote_refs, sought, nr_sought,
&shallow, pack_lockfiles_ptr, version);
@@ -280,9 +288,13 @@ int cmd_fetch_pack(int argc,
oid_to_hex(&ref->old_oid), ref->name);
for (size_t i = 0; i < nr_sought; i++)
- free_one_ref(sought[i]);
+ free_one_ref(sought_to_free[i]);
+ free(sought_to_free);
free(sought);
free_refs(fetched_refs);
free_refs(remote_refs);
+ list_objects_filter_release(&args.filter_options);
+ oid_array_clear(&shallow);
+ string_list_clear(&pack_lockfiles, 0);
return ret;
}
diff --git a/builtin/fetch.c b/builtin/fetch.c
index c900f57721..80a64d0d26 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -456,6 +456,7 @@ static void filter_prefetch_refspec(struct refspec *rs)
free(rs->items[i].src);
free(rs->items[i].dst);
+ free(rs->raw[i]);
for (j = i + 1; j < rs->nr; j++) {
rs->items[j - 1] = rs->items[j];
diff --git a/builtin/push.c b/builtin/push.c
index e6f48969b8..59d4485603 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -669,6 +669,7 @@ int cmd_push(int argc,
rc = do_push(flags, push_options, remote);
string_list_clear(&push_options_cmdline, 0);
string_list_clear(&push_options_config, 0);
+ clear_cas_option(&cas);
if (rc == -1)
usage_with_options(push_usage, options);
else
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index 81fc96d423..8b1d46e79a 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -343,5 +343,7 @@ int cmd_send_pack(int argc,
free_refs(remote_refs);
free_refs(local_refs);
refspec_clear(&rs);
+ oid_array_clear(&shallow);
+ clear_cas_option(&cas);
return ret;
}