aboutsummaryrefslogtreecommitdiffstats
path: root/builtin
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-06-11 11:21:25 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-11 13:15:08 -0700
commit3332f35577ccbb51a50d88d16caafcceaab23767 (patch)
treefc04475a6d497eebc65cfb9a78b7a625892875be /builtin
parentblame: fix leaking data for blame scoreboards (diff)
downloadgit-3332f35577ccbb51a50d88d16caafcceaab23767.tar.gz
git-3332f35577ccbb51a50d88d16caafcceaab23767.zip
builtin/blame: fix leaking prefixed paths
In `cmd_blame()` we compute prefixed paths by calling `add_prefix()`, which itself calls `prefix_path()`. While `prefix_path()` returns an allocated string, `add_prefix()` pretends to return a constant string. Consequently, this path never gets freed. Fix the return type to be `char *` and free the path to plug the memory leak. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/blame.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index e09ff0155a..17694410ed 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -687,7 +687,7 @@ static unsigned parse_score(const char *arg)
return score;
}
-static const char *add_prefix(const char *prefix, const char *path)
+static char *add_prefix(const char *prefix, const char *path)
{
return prefix_path(prefix, prefix ? strlen(prefix) : 0, path);
}
@@ -865,7 +865,7 @@ static void build_ignorelist(struct blame_scoreboard *sb,
int cmd_blame(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
- const char *path;
+ char *path = NULL;
struct blame_scoreboard sb;
struct blame_origin *o;
struct blame_entry *ent = NULL;
@@ -1226,6 +1226,7 @@ parse_done:
}
cleanup:
+ free(path);
cleanup_scoreboard(&sb);
release_revisions(&revs);
return 0;