git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] midx: fix broken free() in close_midx()

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 8, 2018, 15:17 UTC
Message-ID
<9fcbbe336dffb16b7cb5f4de0163404a81597af1.1539011820.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.27.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 f3e8dbc108..999717b96f 100644
--- a/midx.c
+++ b/midx.c
@@ -190,7 +190,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
Previous: Derrick Stolee via GitGitGadgetNext: Junio C Hamano
Message 2 of 14 in “Add GIT_TEST_MULTI_PACK_INDEX environment variable”
  1. 0/3 Add GIT_TEST_MULTI_PACK_INDEX environment variableDerrick Stolee via GitGitGadget, Oct 8, 2018
  2. 1/3 midx: fix broken free() in close_midx()Derrick Stolee via GitGitGadget, Oct 8, 2018
  3. Junio C HamanoOct 9, 2018
  4. 2/3 midx: close multi-pack-index on repackDerrick Stolee via GitGitGadget, Oct 8, 2018
  5. Junio C HamanoOct 9, 2018
  6. Derrick StoleeOct 9, 2018
  7. Stefan BellerOct 9, 2018
  8. 3/3 multi-pack-index: define GIT_TEST_MULTI_PACK_INDEXDerrick Stolee via GitGitGadget, Oct 8, 2018
  9. 0/3 Add GIT_TEST_MULTI_PACK_INDEX environment variableDerrick Stolee via GitGitGadget, Oct 12, 2018
  10. 1/3 midx: fix broken free() in close_midx()Derrick Stolee via GitGitGadget, Oct 12, 2018
  11. 3/3 multi-pack-index: define GIT_TEST_MULTI_PACK_INDEXDerrick Stolee via GitGitGadget, Oct 12, 2018
  12. 2/3 midx: close multi-pack-index on repackDerrick Stolee via GitGitGadget, Oct 12, 2018
  13. Derrick StoleeOct 12, 2018
  14. Junio C HamanoOct 22, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.