All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] revision: fix memory leak in prepare_show_merge()
@ 2025-06-04  3:08 Lidong Yan via GitGitGadget
  2025-06-04  7:48 ` Patrick Steinhardt
  2025-06-09  8:16 ` [PATCH v2] " Lidong Yan via GitGitGadget
  0 siblings, 2 replies; 12+ messages in thread
From: Lidong Yan via GitGitGadget @ 2025-06-04  3:08 UTC (permalink / raw)
  To: git; +Cc: Lidong Yan, Lidong Yan

From: Lidong Yan <502024330056@smail.nju.edu.cn>

In revision.c:prepare_show_merge(), we allocated an array in prune
but forget to free it. Since parse_pathspec is not responsible to
free prune, we should add `free(prune)` in the end of prepare_show_merge().

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
---
    revision: fix memory leak in prepare_show_merge()
    
    In revision.c:prepare_show_merge(), we allocated an array in prune but
    forget to free it. Since parse_pathspec is not responsible to free
    prune, we should add free(prune) in the end of prepare_show_merge().

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1989%2Fbrandb97%2Ffix-revision-leak-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1989/brandb97/fix-revision-leak-v1
Pull-Request: https://github.com/git/git/pull/1989

 revision.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/revision.c b/revision.c
index 2c36a9c179e..afee1111961 100644
--- a/revision.c
+++ b/revision.c
@@ -2060,6 +2060,7 @@ static void prepare_show_merge(struct rev_info *revs)
 	parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
 		       PATHSPEC_PREFER_FULL | PATHSPEC_LITERAL_PATH, "", prune);
 	revs->limited = 1;
+	free(prune);
 }
 
 static int dotdot_missing(const char *arg, char *dotdot,

base-commit: 7014b55638da979331baf8dc31c4e1d697cf2d67
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-06-10  0:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-04  3:08 [PATCH] revision: fix memory leak in prepare_show_merge() Lidong Yan via GitGitGadget
2025-06-04  7:48 ` Patrick Steinhardt
2025-06-04  7:53   ` lidongyan
2025-06-04  8:06     ` Patrick Steinhardt
2025-06-04 10:25       ` lidongyan
2025-06-05 20:56   ` Junio C Hamano
2025-06-06  7:31     ` lidongyan
2025-06-06 16:47       ` Junio C Hamano
2025-06-09  3:10         ` lidongyan
2025-06-09  8:16 ` [PATCH v2] " Lidong Yan via GitGitGadget
2025-06-09 20:48   ` Junio C Hamano
2025-06-10  0:37   ` [PATCH v3] " Lidong Yan via GitGitGadget

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.