All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Derrick Stolee <dstolee@microsoft.com>
Subject: [PATCH v2 1/3] midx: fix broken free() in close_midx()
Date: Fri, 12 Oct 2018 10:34:17 -0700 (PDT)	[thread overview]
Message-ID: <8bd672fe26574972043bc7e041e693c3e17d20a1.1539365654.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.27.v2.git.gitgitgadget@gmail.com>

From: Derrick Stolee <dstolee@microsoft.com>

When closing a multi-pack-index, we intend to close each pack-file
and free the struct packed_git that represents it. However, this
line was previously freeing the array of pointers, not the
pointer itself. This leads to a double-free issue.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 midx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/midx.c b/midx.c
index 713d6f9dde..bf1f511862 100644
--- a/midx.c
+++ b/midx.c
@@ -186,7 +186,7 @@ static void close_midx(struct multi_pack_index *m)
 	for (i = 0; i < m->num_packs; i++) {
 		if (m->packs[i]) {
 			close_pack(m->packs[i]);
-			free(m->packs);
+			free(m->packs[i]);
 		}
 	}
 	FREE_AND_NULL(m->packs);
-- 
gitgitgadget


  reply	other threads:[~2018-10-12 17:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-08 15:17 [PATCH 0/3] Add GIT_TEST_MULTI_PACK_INDEX environment variable Derrick Stolee via GitGitGadget
2018-10-08 15:17 ` [PATCH 1/3] midx: fix broken free() in close_midx() Derrick Stolee via GitGitGadget
2018-10-09  9:07   ` Junio C Hamano
2018-10-08 15:17 ` [PATCH 2/3] midx: close multi-pack-index on repack Derrick Stolee via GitGitGadget
2018-10-09  9:10   ` Junio C Hamano
2018-10-09 14:11     ` Derrick Stolee
2018-10-09 18:15       ` Stefan Beller
2018-10-08 15:17 ` [PATCH 3/3] multi-pack-index: define GIT_TEST_MULTI_PACK_INDEX Derrick Stolee via GitGitGadget
2018-10-12 17:34 ` [PATCH v2 0/3] Add GIT_TEST_MULTI_PACK_INDEX environment variable Derrick Stolee via GitGitGadget
2018-10-12 17:34   ` Derrick Stolee via GitGitGadget [this message]
2018-10-12 17:34   ` [PATCH v2 2/3] midx: close multi-pack-index on repack Derrick Stolee via GitGitGadget
2018-10-12 17:34   ` [PATCH v2 3/3] multi-pack-index: define GIT_TEST_MULTI_PACK_INDEX Derrick Stolee via GitGitGadget
2018-10-12 17:41   ` [PATCH v2 0/3] Add GIT_TEST_MULTI_PACK_INDEX environment variable Derrick Stolee
2018-10-22  1:41     ` Junio C Hamano

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=8bd672fe26574972043bc7e041e693c3e17d20a1.1539365654.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=dstolee@microsoft.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.