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

[PATCH 1/2] double free in builtin-update-index.c

From
Pierre Habouzit <madcoder@debian.org>
Date
Sep 27, 2007, 10:51 UTC
Message-ID
<20070927110456.50993930B@madism.org>
In-Reply-To
<20070927101300.GD10289@artemis.corp>

path_name is either ptr that should not be freed, or a pointer to a strbuf buffer that is deallocated when exiting the loop. Don't do that !

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
 builtin-update-index.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/builtin-update-index.c b/builtin-update-index.c
index c76879e..e1a938d 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -377,8 +377,6 @@ static void read_index_info(int line_termination)
 				die("git-update-index: unable to update %s",
 				    path_name);
 		}
-		if (path_name != ptr)
-			free(path_name);
 		continue;
 
 	bad_line:
-- 
1.5.3.2.1100.g015a-dirty
Previous: Pierre HabouzitNext: Pierre Habouzit
Message 3 of 10 in “Use of strbuf.buf when strbuf.len == 0”
  1. Junio C HamanoSep 27, 2007
  2. Pierre HabouzitSep 27, 2007
  3. 1/2 double free in builtin-update-index.cPierre Habouzit, Sep 27, 2007
  4. 2/2 strbuf change: be sure ->buf is never ever NULL.Pierre Habouzit, Sep 27, 2007
  5. Linus TorvaldsSep 29, 2007
  6. Pierre HabouzitSep 29, 2007
  7. Pierre HabouzitSep 27, 2007
  8. 1/1 Make read_patch_file work on a strbuf.Pierre Habouzit, Sep 27, 2007
  9. 1/1 Make read_patch_file work on a strbuf.Pierre Habouzit, Sep 27, 2007
  10. Pierre HabouzitSep 27, 2007

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.