From 443a12f37be1c5967785b83bf04935fe357afb9b Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 8 May 2017 13:21:06 +0900 Subject: checkout: fix memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When "git checkout -m" does an in-core three-way merge to carry local modifications forward to check out a different branch, the code forgot to free the updated contents it has in-core. Noticed-by: René Scharfe Signed-off-by: Junio C Hamano --- builtin/checkout.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/checkout.c b/builtin/checkout.c index 5faea3a05f..94849cf250 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -247,6 +247,7 @@ static int checkout_merged(int pos, const struct checkout *state) if (write_sha1_file(result_buf.ptr, result_buf.size, blob_type, oid.hash)) die(_("Unable to add merge result for '%s'"), path); + free(result_buf.ptr); ce = make_cache_entry(mode, oid.hash, path, 2, 0); if (!ce) die(_("make_cache_entry failed for path '%s'"), path); -- cgit v1.2.3