diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-05-30 14:51:29 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-30 14:51:29 +0200 |
commit | e47dbece39712567a36a096010c5c1223119f7e3 (patch) | |
tree | aced74e797a0c37931e367574bdd60cbfb63e0f4 /merge-recursive.c | |
parent | Merge branch 'bc/hash-independent-tests' (diff) | |
parent | unpack_trees_options: free messages when done (diff) | |
download | git-e47dbece39712567a36a096010c5c1223119f7e3.tar.xz git-e47dbece39712567a36a096010c5c1223119f7e3.zip |
Merge branch 'ma/unpack-trees-free-msgs'
Leak plugging.
* ma/unpack-trees-free-msgs:
unpack_trees_options: free messages when done
argv-array: return the pushed string from argv_push*()
merge-recursive: provide pair of `unpack_trees_{start,finish}()`
merge: setup `opts` later in `checkout_fast_forward()`
Diffstat (limited to 'merge-recursive.c')
-rw-r--r-- | merge-recursive.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/merge-recursive.c b/merge-recursive.c index cf5341828f..ac27abbd4c 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -338,10 +338,10 @@ static void init_tree_desc_from_tree(struct tree_desc *desc, struct tree *tree) init_tree_desc(desc, tree->buffer, tree->size); } -static int git_merge_trees(struct merge_options *o, - struct tree *common, - struct tree *head, - struct tree *merge) +static int unpack_trees_start(struct merge_options *o, + struct tree *common, + struct tree *head, + struct tree *merge) { int rc; struct tree_desc t[3]; @@ -380,6 +380,12 @@ static int git_merge_trees(struct merge_options *o, return rc; } +static void unpack_trees_finish(struct merge_options *o) +{ + discard_index(&o->orig_index); + clear_unpack_trees_porcelain(&o->unpack_opts); +} + struct tree *write_tree_from_memory(struct merge_options *o) { struct tree *result = NULL; @@ -3267,13 +3273,14 @@ int merge_trees(struct merge_options *o, return 1; } - code = git_merge_trees(o, common, head, merge); + code = unpack_trees_start(o, common, head, merge); if (code != 0) { if (show(o, 4) || o->call_depth) err(o, _("merging of trees %s and %s failed"), oid_to_hex(&head->object.oid), oid_to_hex(&merge->object.oid)); + unpack_trees_finish(o); return -1; } @@ -3326,20 +3333,15 @@ cleanup: hashmap_free(&o->current_file_dir_set, 1); - if (clean < 0) + if (clean < 0) { + unpack_trees_finish(o); return clean; + } } else clean = 1; - /* Free the extra index left from git_merge_trees() */ - /* - * FIXME: Need to also free data allocated by - * setup_unpack_trees_porcelain() tucked away in o->unpack_opts.msgs, - * but the problem is that only half of it refers to dynamically - * allocated data, while the other half points at static strings. - */ - discard_index(&o->orig_index); + unpack_trees_finish(o); if (o->call_depth && !(*result = write_tree_from_memory(o))) return -1; |