git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Ramkumar Ramachandra <artagnon@gmail.com>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Nick Bowler <nbowler@elliptictech.com>
Subject: [PATCH 7/7] Properly free unpack trees error messages
Date: Mon, 21 May 2012 16:56:09 +0200	[thread overview]
Message-ID: <20120521145610.1911.31963.chriscool@tuxfamily.org> (raw)
In-Reply-To: <20120521143309.1911.94302.chriscool@tuxfamily.org>


Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 builtin/checkout.c | 1 +
 builtin/merge.c    | 6 ++++--
 merge-recursive.c  | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 3ddda34..df8fef0 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -435,6 +435,7 @@ static int merge_working_tree(struct checkout_opts *opts,
 		init_tree_desc(&trees[1], tree->buffer, tree->size);
 
 		ret = unpack_trees(2, trees, &topts);
+		free_unpack_error_msgs(&topts);
 		if (ret == -1) {
 			/*
 			 * Unpack couldn't do a trivial merge; either
diff --git a/builtin/merge.c b/builtin/merge.c
index 470fc57..b96a9ae 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -768,7 +768,7 @@ int checkout_fast_forward(const unsigned char *head, const unsigned char *remote
 	struct tree *trees[MAX_UNPACK_TREES];
 	struct unpack_trees_options opts;
 	struct tree_desc t[MAX_UNPACK_TREES];
-	int i, fd, nr_trees = 0;
+	int i, fd, res, nr_trees = 0;
 	struct dir_struct dir;
 	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 
@@ -805,7 +805,9 @@ int checkout_fast_forward(const unsigned char *head, const unsigned char *remote
 		parse_tree(trees[i]);
 		init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);
 	}
-	if (unpack_trees(nr_trees, t, &opts))
+	res = unpack_trees(nr_trees, t, &opts);
+	free_unpack_error_msgs(&opts);
+	if (res)
 		return -1;
 	if (write_cache(fd, active_cache, active_nr) ||
 		commit_locked_index(lock_file))
diff --git a/merge-recursive.c b/merge-recursive.c
index 9c3570a..e196c45 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -239,6 +239,7 @@ static int git_merge_trees(int index_only,
 	init_tree_desc_from_tree(t+2, merge);
 
 	rc = unpack_trees(3, t, &opts);
+	free_unpack_error_msgs(&opts);
 	cache_tree_free(&active_cache_tree);
 	return rc;
 }
-- 
1.7.10.2.555.g6528037

      parent reply	other threads:[~2012-05-21 15:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 14:56 [PATCH 0/7] Fix some sequencer leaks Christian Couder
2012-05-21 14:56 ` [PATCH 1/7] sequencer: fix leaked todo_list memory Christian Couder
2012-05-21 20:57   ` Jonathan Nieder
2012-05-22 20:24     ` Christian Couder
2012-05-21 14:56 ` [PATCH 2/7] sequencer: release a strbuf used in save_head() Christian Couder
2012-05-22  4:12   ` Ramkumar Ramachandra
2012-05-22  4:23     ` Jonathan Nieder
2012-05-22  5:07       ` Ramkumar Ramachandra
2012-05-22  5:18         ` Jonathan Nieder
2012-05-22 14:17   ` Jonathan Nieder
2012-05-22 20:30     ` Christian Couder
2012-05-21 14:56 ` [PATCH 3/7] merge-recursive: free some string lists Christian Couder
2012-05-21 14:56 ` [PATCH 4/7] revert: free opts.revs to do a bit of cleanup Christian Couder
2012-05-22  5:14   ` Ramkumar Ramachandra
2012-05-22 20:03     ` Christian Couder
2012-05-21 14:56 ` [PATCH 5/7] revert: free revs->cmdline.rev Christian Couder
2012-05-21 20:39   ` Jonathan Nieder
2012-05-22 20:01     ` Christian Couder
2012-05-22 20:40       ` Jonathan Nieder
2012-05-21 14:56 ` [PATCH 6/7] unpack-trees: record which unpack error messages should be freed Christian Couder
2012-05-21 20:43   ` Jonathan Nieder
2012-05-22 20:22     ` Christian Couder
2012-05-21 14:56 ` Christian Couder [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120521145610.1911.31963.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=nbowler@elliptictech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).