From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Patrick Steinhardt <ps@pks.im>
Subject: [PATCH] xdiff/xmerge: fix memory leak in xdl_merge
Date: Tue, 23 Feb 2016 09:45:51 +0100 [thread overview]
Message-ID: <1456217151-16473-1-git-send-email-ps@pks.im> (raw)
When building the script for the second file that is to be merged
we have already allocated memory for data structures related to
the first file. When we encounter an error in building the second
script we only free allocated memory related to the second file
before erroring out.
Fix this memory leak by also releasing allocated memory related
to the first file.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
xdiff/xmerge.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index d98f430..d04eb46 100644
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -654,6 +654,8 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,
if (xdl_change_compact(&xe2.xdf1, &xe2.xdf2, xpp->flags) < 0 ||
xdl_change_compact(&xe2.xdf2, &xe2.xdf1, xpp->flags) < 0 ||
xdl_build_script(&xe2, &xscr2) < 0) {
+ xdl_free_script(xscr1);
+ xdl_free_env(&xe1);
xdl_free_env(&xe2);
return -1;
}
--
2.7.1
next reply other threads:[~2016-02-23 8:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-23 8:45 Patrick Steinhardt [this message]
2016-02-23 10:09 ` [PATCH] xdiff/xmerge: fix memory leak in xdl_merge Johannes Schindelin
2016-02-23 11:51 ` Patrick Steinhardt
2016-02-23 11:59 ` [PATCH v2] " Patrick Steinhardt
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=1456217151-16473-1-git-send-email-ps@pks.im \
--to=ps@pks.im \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).