summaryrefslogtreecommitdiff
path: root/reset.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-08-04 13:28:52 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-08-04 13:28:52 -0700
commit31f9acf9ce29ae210b54997f7fb388a2dc543d53 (patch)
treeec42e72471831dd47a31bd467e32b4bce6499be7 /reset.c
parentMerge branch 'ar/submodule-add' (diff)
parentreset: clear_unpack_trees_porcelain to plug leak (diff)
downloadtgif-31f9acf9ce29ae210b54997f7fb388a2dc543d53.tar.xz
Merge branch 'ah/plugleaks'
Leak plugging. * ah/plugleaks: reset: clear_unpack_trees_porcelain to plug leak builtin/rebase: fix options.strategy memory lifecycle builtin/merge: free found_ref when done builtin/mv: free or UNLEAK multiple pointers at end of cmd_mv convert: release strbuf to avoid leak read-cache: call diff_setup_done to avoid leak ref-filter: also free head for ATOM_HEAD to avoid leak diffcore-rename: move old_dir/new_dir definition to plug leak builtin/for-each-repo: remove unnecessary argv copy to plug leak builtin/submodule--helper: release unused strbuf to avoid leak environment: move strbuf into block to plug leak fmt-merge-msg: free newly allocated temporary strings when done
Diffstat (limited to 'reset.c')
-rw-r--r--reset.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/reset.c b/reset.c
index 4bea758053..79310ae071 100644
--- a/reset.c
+++ b/reset.c
@@ -21,7 +21,7 @@ int reset_head(struct repository *r, struct object_id *oid, const char *action,
struct object_id head_oid;
struct tree_desc desc[2] = { { NULL }, { NULL } };
struct lock_file lock = LOCK_INIT;
- struct unpack_trees_options unpack_tree_opts;
+ struct unpack_trees_options unpack_tree_opts = { 0 };
struct tree *tree;
const char *reflog_action;
struct strbuf msg = STRBUF_INIT;
@@ -49,7 +49,6 @@ int reset_head(struct repository *r, struct object_id *oid, const char *action,
if (refs_only)
goto reset_head_refs;
- memset(&unpack_tree_opts, 0, sizeof(unpack_tree_opts));
setup_unpack_trees_porcelain(&unpack_tree_opts, action);
unpack_tree_opts.head_idx = 1;
unpack_tree_opts.src_index = r->index;
@@ -134,6 +133,7 @@ reset_head_refs:
leave_reset_head:
strbuf_release(&msg);
rollback_lock_file(&lock);
+ clear_unpack_trees_porcelain(&unpack_tree_opts);
while (nr)
free((void *)desc[--nr].buffer);
return ret;