From: Taylor Blau <me@ttaylorr.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, James Liu <james@jamesliu.io>,
Phillip Wood <phillip.wood123@gmail.com>
Subject: Re: [PATCH v2 02/22] git: fix leaking system paths
Date: Mon, 12 Aug 2024 10:11:05 -0400 [thread overview]
Message-ID: <ZroX+SSgTe7YnWHS@nand.local> (raw)
In-Reply-To: <324140e4fdee54fbf0054e76abb287b7212fd21e.1723121979.git.ps@pks.im>
On Thu, Aug 08, 2024 at 03:04:39PM +0200, Patrick Steinhardt wrote:
> Git has some flags to make it output system paths as they have been
> compiled into Git. This is done by calling `system_path()`, which
> returns an allocated string. This string isn't ever free'd though,
> creating a memory leak.
>
> Plug those leaks. While they are surfaced by t0211, there are more
> memory leaks looming exposed by that test suite and it thus does not yet
> pass with the memory leak checker enabled.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> git.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/git.c b/git.c
> index e35af9b0e5..5eab88b472 100644
> --- a/git.c
> +++ b/git.c
> @@ -173,15 +173,21 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
> exit(0);
> }
> } else if (!strcmp(cmd, "--html-path")) {
> - puts(system_path(GIT_HTML_PATH));
> + char *path = system_path(GIT_HTML_PATH);
> + puts(path);
> + free(path);
> trace2_cmd_name("_query_");
> exit(0);
> } else if (!strcmp(cmd, "--man-path")) {
> - puts(system_path(GIT_MAN_PATH));
> + char *path = system_path(GIT_MAN_PATH);
> + puts(path);
> + free(path);
> trace2_cmd_name("_query_");
> exit(0);
> } else if (!strcmp(cmd, "--info-path")) {
> - puts(system_path(GIT_INFO_PATH));
> + char *path = system_path(GIT_INFO_PATH);
> + puts(path);
> + free(path);
> trace2_cmd_name("_query_");
> exit(0);
> } else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
Makes sense, though I wonder if this would be slightly cleaner to write
like so (applies on top of this patch):
--- 8< ---
diff --git a/git.c b/git.c
index 5eab88b472..9a618a2740 100644
--- a/git.c
+++ b/git.c
@@ -143,6 +143,13 @@ void setup_auto_pager(const char *cmd, int def)
commit_pager_choice();
}
+static void print_system_path(const char *path)
+{
+ char *s_path = system_path(path);
+ puts(s_path);
+ free(s_path);
+}
+
static int handle_options(const char ***argv, int *argc, int *envchanged)
{
const char **orig_argv = *argv;
@@ -173,21 +180,15 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
exit(0);
}
} else if (!strcmp(cmd, "--html-path")) {
- char *path = system_path(GIT_HTML_PATH);
- puts(path);
- free(path);
+ print_system_path(GIT_HTML_PATH);
trace2_cmd_name("_query_");
exit(0);
} else if (!strcmp(cmd, "--man-path")) {
- char *path = system_path(GIT_MAN_PATH);
- puts(path);
- free(path);
+ print_system_path(GIT_MAN_PATH);
trace2_cmd_name("_query_");
exit(0);
} else if (!strcmp(cmd, "--info-path")) {
- char *path = system_path(GIT_INFO_PATH);
- puts(path);
- free(path);
+ print_system_path(GIT_INFO_PATH);
trace2_cmd_name("_query_");
exit(0);
} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
--- >8 ---
Thanks,
Taylor
next prev parent reply other threads:[~2024-08-12 14:11 UTC|newest]
Thread overview: 146+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-06 8:59 [PATCH 00/22] Memory leak fixes (pt.4) Patrick Steinhardt
2024-08-06 8:59 ` [PATCH 01/22] remote: plug memory leak when aliasing URLs Patrick Steinhardt
2024-08-06 8:59 ` [PATCH 02/22] git: fix leaking system paths Patrick Steinhardt
2024-08-07 4:02 ` James Liu
2024-08-06 8:59 ` [PATCH 03/22] object-file: fix memory leak when reading corrupted headers Patrick Steinhardt
2024-08-06 8:59 ` [PATCH 04/22] object-name: fix leaking symlink paths in object context Patrick Steinhardt
2024-08-06 8:59 ` [PATCH 05/22] bulk-checkin: fix leaking state TODO Patrick Steinhardt
2024-08-06 9:00 ` [PATCH 06/22] read-cache: fix leaking hashfile when writing index fails Patrick Steinhardt
2024-08-07 7:01 ` James Liu
2024-08-08 5:04 ` Patrick Steinhardt
2024-08-06 9:00 ` [PATCH 07/22] submodule-config: fix leaking name enrty when traversing submodules Patrick Steinhardt
2024-08-06 9:00 ` [PATCH 08/22] config: fix leaking comment character config Patrick Steinhardt
2024-08-07 7:11 ` James Liu
2024-08-08 5:04 ` Patrick Steinhardt
2024-08-08 15:54 ` Junio C Hamano
2024-08-06 9:00 ` [PATCH 09/22] builtin/rebase: fix leaking `commit.gpgsign` value Patrick Steinhardt
2024-08-07 7:32 ` James Liu
2024-08-08 5:05 ` Patrick Steinhardt
2024-08-08 10:07 ` Phillip Wood
2024-08-08 12:58 ` Patrick Steinhardt
2024-08-06 9:00 ` [PATCH 10/22] builtin/notes: fix leaking `struct notes_tree` when merging notes Patrick Steinhardt
2024-08-06 9:00 ` [PATCH 11/22] builtin/fast-import: plug trivial memory leaks Patrick Steinhardt
2024-08-06 9:00 ` [PATCH 12/22] builtin/fast-export: fix leaking diff options Patrick Steinhardt
2024-08-06 9:00 ` [PATCH 13/22] builtin/fast-export: plug leaking tag names Patrick Steinhardt
2024-08-07 8:31 ` James Liu
2024-08-08 5:05 ` Patrick Steinhardt
2024-08-06 9:00 ` [PATCH 14/22] merge-ort: unconditionally release attributes index Patrick Steinhardt
2024-08-06 9:00 ` [PATCH 15/22] sequencer: release todo list on error paths Patrick Steinhardt
2024-08-08 10:08 ` Phillip Wood
2024-08-08 16:31 ` Junio C Hamano
2024-08-06 9:00 ` [PATCH 16/22] unpack-trees: clear index when not propagating it Patrick Steinhardt
2024-08-06 9:00 ` [PATCH 17/22] diff: fix leak when parsing invalid ignore regex option Patrick Steinhardt
2024-08-06 9:00 ` [PATCH 18/22] builtin/format-patch: fix various trivial memory leaks Patrick Steinhardt
2024-08-07 8:51 ` James Liu
2024-08-08 5:05 ` Patrick Steinhardt
2024-08-06 9:01 ` [PATCH 19/22] userdiff: fix leaking memory for configured diff drivers Patrick Steinhardt
2024-08-07 9:25 ` James Liu
2024-08-08 5:05 ` Patrick Steinhardt
2024-08-08 16:05 ` Junio C Hamano
2024-08-06 9:01 ` [PATCH 20/22] builtin/log: fix leak when showing converted blob contents Patrick Steinhardt
2024-08-06 9:01 ` [PATCH 21/22] diff: free state populated via options Patrick Steinhardt
2024-08-06 9:01 ` [PATCH 22/22] builtin/diff: free symmetric diff members Patrick Steinhardt
2024-08-07 9:27 ` [PATCH 00/22] Memory leak fixes (pt.4) James Liu
2024-08-08 5:05 ` Patrick Steinhardt
2024-08-08 6:00 ` James Liu
2024-08-07 16:59 ` Junio C Hamano
2024-08-07 17:03 ` Patrick Steinhardt
2024-08-08 0:32 ` Junio C Hamano
2024-08-08 13:04 ` [PATCH v2 " Patrick Steinhardt
2024-08-08 13:04 ` [PATCH v2 01/22] remote: plug memory leak when aliasing URLs Patrick Steinhardt
2024-08-12 8:27 ` karthik nayak
2024-08-12 14:08 ` Taylor Blau
2024-08-12 14:37 ` Jeff King
2024-08-13 6:34 ` Patrick Steinhardt
2024-08-08 13:04 ` [PATCH v2 02/22] git: fix leaking system paths Patrick Steinhardt
2024-08-12 14:11 ` Taylor Blau [this message]
2024-08-13 6:30 ` Patrick Steinhardt
2024-08-13 16:02 ` Junio C Hamano
2024-08-08 13:04 ` [PATCH v2 03/22] object-file: fix memory leak when reading corrupted headers Patrick Steinhardt
2024-08-12 8:43 ` karthik nayak
2024-08-08 13:04 ` [PATCH v2 04/22] object-name: fix leaking symlink paths in object context Patrick Steinhardt
2024-08-08 13:04 ` [PATCH v2 05/22] bulk-checkin: fix leaking state TODO Patrick Steinhardt
2024-08-08 13:04 ` [PATCH v2 06/22] read-cache: fix leaking hashfile when writing index fails Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 07/22] submodule-config: fix leaking name enrty when traversing submodules Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 08/22] config: fix leaking comment character config Patrick Steinhardt
2024-08-08 17:12 ` Junio C Hamano
2024-08-12 7:45 ` Patrick Steinhardt
2024-08-12 20:32 ` Junio C Hamano
2024-08-13 6:54 ` Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 09/22] builtin/rebase: fix leaking `commit.gpgsign` value Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 10/22] builtin/notes: fix leaking `struct notes_tree` when merging notes Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 11/22] builtin/fast-import: plug trivial memory leaks Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 12/22] builtin/fast-export: fix leaking diff options Patrick Steinhardt
2024-08-12 9:05 ` karthik nayak
2024-08-08 13:05 ` [PATCH v2 13/22] builtin/fast-export: plug leaking tag names Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 14/22] merge-ort: unconditionally release attributes index Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 15/22] sequencer: release todo list on error paths Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 16/22] unpack-trees: clear index when not propagating it Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 17/22] diff: fix leak when parsing invalid ignore regex option Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 18/22] builtin/format-patch: fix various trivial memory leaks Patrick Steinhardt
2024-08-08 13:05 ` [PATCH v2 19/22] userdiff: fix leaking memory for configured diff drivers Patrick Steinhardt
2024-08-08 13:06 ` [PATCH v2 20/22] builtin/log: fix leak when showing converted blob contents Patrick Steinhardt
2024-08-08 13:06 ` [PATCH v2 21/22] diff: free state populated via options Patrick Steinhardt
2024-08-08 13:06 ` [PATCH v2 22/22] builtin/diff: free symmetric diff members Patrick Steinhardt
2024-08-12 9:12 ` karthik nayak
2024-08-12 9:13 ` [PATCH v2 00/22] Memory leak fixes (pt.4) karthik nayak
2024-08-12 15:49 ` Junio C Hamano
2024-08-13 6:27 ` Patrick Steinhardt
2024-08-12 14:01 ` Phillip Wood
2024-08-12 15:50 ` Junio C Hamano
2024-08-13 9:31 ` [PATCH v3 " Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 01/22] remote: plug memory leak when aliasing URLs Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 02/22] git: fix leaking system paths Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 03/22] object-file: fix memory leak when reading corrupted headers Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 04/22] object-name: fix leaking symlink paths in object context Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 05/22] bulk-checkin: fix leaking state TODO Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 06/22] read-cache: fix leaking hashfile when writing index fails Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 07/22] submodule-config: fix leaking name entry when traversing submodules Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 08/22] config: fix leaking comment character config Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 09/22] builtin/rebase: fix leaking `commit.gpgsign` value Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 10/22] builtin/notes: fix leaking `struct notes_tree` when merging notes Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 11/22] builtin/fast-import: plug trivial memory leaks Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 12/22] builtin/fast-export: fix leaking diff options Patrick Steinhardt
2024-08-13 16:34 ` Junio C Hamano
2024-08-14 4:49 ` Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 13/22] builtin/fast-export: plug leaking tag names Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 14/22] merge-ort: unconditionally release attributes index Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 15/22] sequencer: release todo list on error paths Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 16/22] unpack-trees: clear index when not propagating it Patrick Steinhardt
2024-08-13 9:31 ` [PATCH v3 17/22] diff: fix leak when parsing invalid ignore regex option Patrick Steinhardt
2024-08-13 9:32 ` [PATCH v3 18/22] builtin/format-patch: fix various trivial memory leaks Patrick Steinhardt
2024-08-13 16:55 ` Junio C Hamano
2024-08-14 4:56 ` Patrick Steinhardt
2024-08-13 16:55 ` Junio C Hamano
2024-08-13 9:32 ` [PATCH v3 19/22] userdiff: fix leaking memory for configured diff drivers Patrick Steinhardt
2024-08-13 9:32 ` [PATCH v3 20/22] builtin/log: fix leak when showing converted blob contents Patrick Steinhardt
2024-08-13 9:32 ` [PATCH v3 21/22] diff: free state populated via options Patrick Steinhardt
2024-08-13 16:31 ` Junio C Hamano
2024-08-13 9:32 ` [PATCH v3 22/22] builtin/diff: free symmetric diff members Patrick Steinhardt
2024-08-13 16:25 ` Junio C Hamano
2024-08-14 5:01 ` Patrick Steinhardt
2024-08-14 15:28 ` Junio C Hamano
2024-08-13 16:58 ` [PATCH v3 00/22] Memory leak fixes (pt.4) Junio C Hamano
2024-08-14 6:51 ` [PATCH v4 " Patrick Steinhardt
2024-08-14 6:51 ` [PATCH v4 01/22] remote: plug memory leak when aliasing URLs Patrick Steinhardt
2024-08-14 6:51 ` [PATCH v4 02/22] git: fix leaking system paths Patrick Steinhardt
2024-08-14 6:51 ` [PATCH v4 03/22] object-file: fix memory leak when reading corrupted headers Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 04/22] object-name: fix leaking symlink paths in object context Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 05/22] bulk-checkin: fix leaking state TODO Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 06/22] read-cache: fix leaking hashfile when writing index fails Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 07/22] submodule-config: fix leaking name entry when traversing submodules Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 08/22] config: fix leaking comment character config Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 09/22] builtin/rebase: fix leaking `commit.gpgsign` value Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 10/22] builtin/notes: fix leaking `struct notes_tree` when merging notes Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 11/22] builtin/fast-import: plug trivial memory leaks Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 12/22] builtin/fast-export: fix leaking diff options Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 13/22] builtin/fast-export: plug leaking tag names Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 14/22] merge-ort: unconditionally release attributes index Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 15/22] sequencer: release todo list on error paths Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 16/22] unpack-trees: clear index when not propagating it Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 17/22] diff: fix leak when parsing invalid ignore regex option Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 18/22] builtin/format-patch: fix various trivial memory leaks Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 19/22] userdiff: fix leaking memory for configured diff drivers Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 20/22] builtin/log: fix leak when showing converted blob contents Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 21/22] diff: free state populated via options Patrick Steinhardt
2024-08-14 6:52 ` [PATCH v4 22/22] builtin/diff: free symmetric diff members Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZroX+SSgTe7YnWHS@nand.local \
--to=me@ttaylorr.com \
--cc=git@vger.kernel.org \
--cc=james@jamesliu.io \
--cc=phillip.wood123@gmail.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).