summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-09-15 23:13:43 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-09-15 23:13:43 (GMT)
commit5098bafb756de69d03882707a3382899c0cb7dd1 (patch)
tree694e88e3a9a2187150f7af09bb9b06a861d7b53b /diff.c
parent98533b90cb8e88484cb381334b19cbf4f7cf92b1 (diff)
downloadgit-5098bafb756de69d03882707a3382899c0cb7dd1.zip
git-5098bafb756de69d03882707a3382899c0cb7dd1.tar.gz
git-5098bafb756de69d03882707a3382899c0cb7dd1.tar.bz2
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: <87y876gl1r.wl@mail2.atmark-techno.com> From: Yasushi SHOJI <yashi@atmark-techno.com> 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. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 05a0663..d8d20c2 100644
--- a/diff.c
+++ b/diff.c
@@ -762,7 +762,8 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *queue,
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_filepair *p)
{
diff_free_filespec_data(p->one);
diff_free_filespec_data(p->two);
+ free(p->one);
+ free(p->two);
free(p);
}