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

[PATCH] fix memleak from tree pathspec in git-blame

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 4, 2007, 06:54 UTC
Message-ID
<7vir6q7wf8.fsf@gitster.siamese.dyndns.org>

We repeatedly run diff-tree while finding code movements. The pathspec data is changed into a list of paths and their lengths for quicker access by diff_tree_setup_paths(), and you need to release the extra memory when you are done using that pathspec data.

Not releasing it is not a problem for "git log -- path" (or its plumbing equivalent "git rev-list -- paths"), because the pathspec never changes during the traversal, but it was noticeable for blame especially with -C -C.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-blame.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index dc88a95..aace08c 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -380,6 +380,7 @@ static struct origin *find_origin(struct scoreboard *sb,
 		}
 	}
 	diff_flush(&diff_opts);
+	diff_tree_release_paths(&diff_opts);
 	if (porigin) {
 		/*
 		 * Create a freestanding copy that is not part of
@@ -436,6 +437,7 @@ static struct origin *find_rename(struct scoreboard *sb,
 		}
 	}
 	diff_flush(&diff_opts);
+	diff_tree_release_paths(&diff_opts);
 	return porigin;
 }
 
@@ -1157,6 +1159,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
 		}
 	}
 	diff_flush(&diff_opts);
+	diff_tree_release_paths(&diff_opts);
 
 	return retval;
 }
Message 1 of 1 in “fix memleak from tree pathspec in git-blame”
  1. fix memleak from tree pathspec in git-blameJunio C Hamano, Sep 4, 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.