Skip to contentSkip to conversation

Plug diff leaks.

PATCH New Junio C Hamano 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Plug diff leaks.

It is a bit embarrassing that it took this long for a fix since the problem was first reported on Aug 13th.

Message-ID: <[email protected]>
From: Yasushi SHOJI <[email protected]>
Newsgroups: gmane.comp.version-control.git
Subject: [patch] possible memory leak in diff.c::diff_free_filepair()
Date: Sat, 13 Aug 2005 19:58:56 +0900

This time I used valgrind to make sure that it does not overeagerly discard memory that is still being used.

---

* this will hopefully be in 0.99.7

 diff-tree.c       |    1 +
 diff.c            |    5 ++++-
 diffcore-rename.c |   56 ++++++++++++++++++++++++++++++-----------------------
 3 files changed, 37 insertions(+), 25 deletions(-)

5098bafb756de69d03882707a3382899c0cb7dd1

diff-tree.c +1 -0
@@ -370,6 +370,7 @@ static int diff_tree_commit(const unsign
 		}
 		offset += 48;
 	}
+	free(buf);
 	return 0;
 }
 
diff.c +4 -1
@@ -762,7 +762,8 @@ struct diff_filepair *diff_queue(struct 
 	dp->status = 0;
 	dp->source_stays = 0;
 	dp->broken_pair = 0;
-	diff_q(queue, dp);
+	if (queue)
+		diff_q(queue, dp);
 	return dp;
 }
 
@@ -770,6 +771,8 @@ void diff_free_filepair(struct diff_file
 {
 	diff_free_filespec_data(p->one);
 	diff_free_filespec_data(p->two);
+	free(p->one);
+	free(p->two);
 	free(p);
 }
 
diffcore-rename.c +32 -24

135 lines not on this page · raw message