[PATCH v2 1/3] midx: fix broken free() in close_midx()
- From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Oct 12, 2018, 17:34 UTC
- Message-ID
- <8bd672fe26574972043bc7e041e693c3e17d20a1.1539365654.git.gitgitgadget@gmail.com>
- 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