git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Subject: [PATCH] diff_flush(): leakfix.
Date: Wed, 05 Apr 2006 02:45:40 -0700	[thread overview]
Message-ID: <7vu0982w57.fsf@assigned-by-dhcp.cox.net> (raw)

We were leaking filepairs when output-format was set to
NO_OUTPUT.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 * This is somewhat embarrassing that the original breakage was
   in a commit on Aug 21, 2005 and the bug stayed there forever
   in git timescale.

 diff.c |   44 +++++++++++++++++++++++++-------------------
 1 files changed, 25 insertions(+), 19 deletions(-)

a12d2890e4d1ada6f9302dea10d151b819e0c0d0
diff --git a/diff.c b/diff.c
index e496905..fe4664c 100644
--- a/diff.c
+++ b/diff.c
@@ -1280,28 +1280,34 @@ void diff_flush(struct diff_options *opt
 
 	for (i = 0; i < q->nr; i++) {
 		struct diff_filepair *p = q->queue[i];
-		if ((diff_output_format == DIFF_FORMAT_NO_OUTPUT) ||
-		    (p->status == DIFF_STATUS_UNKNOWN))
-			continue;
-		if (p->status == 0)
-			die("internal error in diff-resolve-rename-copy");
-		switch (diff_output_format) {
-		case DIFF_FORMAT_PATCH:
-			diff_flush_patch(p, options);
-			break;
-		case DIFF_FORMAT_RAW:
-		case DIFF_FORMAT_NAME_STATUS:
-			diff_flush_raw(p, line_termination,
-				       inter_name_termination,
-				       options);
+
+		switch (p->status) {
+		case DIFF_STATUS_UNKNOWN:
 			break;
-		case DIFF_FORMAT_NAME:
-			diff_flush_name(p,
-					inter_name_termination,
-					line_termination);
+		case 0:
+			die("internal error in diff-resolve-rename-copy");
 			break;
+		default:
+			switch (diff_output_format) {
+			case DIFF_FORMAT_PATCH:
+				diff_flush_patch(p, options);
+				break;
+			case DIFF_FORMAT_RAW:
+			case DIFF_FORMAT_NAME_STATUS:
+				diff_flush_raw(p, line_termination,
+					       inter_name_termination,
+					       options);
+				break;
+			case DIFF_FORMAT_NAME:
+				diff_flush_name(p,
+						inter_name_termination,
+						line_termination);
+				break;
+			case DIFF_FORMAT_NO_OUTPUT:
+				break;
+			}
 		}
-		diff_free_filepair(q->queue[i]);
+		diff_free_filepair(p);
 	}
 	free(q->queue);
 	q->queue = NULL;
-- 
1.3.0.rc2.g110c

                 reply	other threads:[~2006-04-05  9:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7vu0982w57.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).