git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Patrick Steinhardt <ps@pks.im>, phillip.wood@dunelm.org.uk
Cc: git@vger.kernel.org
Subject: Re: [PATCH 20/29] sequencer: fix leaking string buffer in `commit_staged_changes()`
Date: Tue, 4 Jun 2024 14:58:17 +0100	[thread overview]
Message-ID: <396e6893-80d4-48f5-b43f-a30684a64bac@gmail.com> (raw)
In-Reply-To: <Zl6_6Z6Bu-zgOmPs@framework>

Hi Patrick

On 04/06/2024 08:19, Patrick Steinhardt wrote:
> On Tue, Jun 04, 2024 at 08:45:11AM +0200, Patrick Steinhardt wrote:
>> On Mon, Jun 03, 2024 at 02:14:20PM +0100, Phillip Wood wrote:
>>> Hi Patrick
>>>
>>> On 03/06/2024 10:48, Patrick Steinhardt wrote:
>>>> @@ -5259,12 +5277,13 @@ static int commit_staged_changes(struct repository *r,
>>>>    				}
>>>>    			unuse_commit_buffer:
>>>>    				repo_unuse_commit_buffer(r, commit, p);
>>>> -				if (res)
>>>> -					return res;
>>>> +				if (res) {
>>>> +					ret = res;
>>>> +					goto out;
>>>> +				}
>>>
>>> Having 'ret' and 'res' in this block is a bit confusing - we could delete
>>> the declaration for 'res' and  either replace its use with 'ret', or rename
>>> 'ret' to 'res' in this patch.
>>
>> Yeah, let's just drop the local `res` variable here and use `ret`
>> instead.
> 
> For the record, below is the diff to address this. I'll refrain from
> sending out this whole patch series again for now to only address this
> one issue, but will include it if there are more things that need to be
> handled.
> 
> Patrick

This and all the other sequencer changes in this series look good to me

Thanks

Phillip

> diff --git a/sequencer.c b/sequencer.c
> index 9e90084692..cc57a30883 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -5253,7 +5253,6 @@ static int commit_staged_changes(struct repository *r,
>   				 * We need to update the squash message to skip
>   				 * the latest commit message.
>   				 */
> -				int res = 0;
>   				struct commit *commit;
>   				const char *msg;
>   				const char *path = rebase_path_squash_msg();
> @@ -5266,22 +5265,22 @@ static int commit_staged_changes(struct repository *r,
>   
>   				p = repo_logmsg_reencode(r, commit, NULL, encoding);
>   				if (!p)  {
> -					res = error(_("could not parse commit %s"),
> +					ret = error(_("could not parse commit %s"),
>   						    oid_to_hex(&commit->object.oid));
>   					goto unuse_commit_buffer;
>   				}
>   				find_commit_subject(p, &msg);
>   				if (write_message(msg, strlen(msg), path, 0)) {
> -					res = error(_("could not write file: "
> +					ret = error(_("could not write file: "
>   						       "'%s'"), path);
>   					goto unuse_commit_buffer;
>   				}
> +
> +				ret = 0;
>   			unuse_commit_buffer:
>   				repo_unuse_commit_buffer(r, commit, p);
> -				if (res) {
> -					ret = res;
> +				if (ret)
>   					goto out;
> -				}
>   			}
>   		}
>   

  reply	other threads:[~2024-06-04 13:58 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-03  9:46 [PATCH 00/29] Memory leak fixes (pt.2) Patrick Steinhardt
2024-06-03  9:46 ` [PATCH 01/29] revision: fix memory leak when reversing revisions Patrick Steinhardt
2024-06-03  9:46 ` [PATCH 02/29] parse-options: fix leaks for users of OPT_FILENAME Patrick Steinhardt
2024-06-06 10:00   ` Karthik Nayak
2024-06-03  9:46 ` [PATCH 03/29] notes-utils: free note trees when releasing copied notes Patrick Steinhardt
2024-06-06 10:02   ` Karthik Nayak
2024-06-03  9:46 ` [PATCH 04/29] bundle: plug leaks in `create_bundle()` Patrick Steinhardt
2024-06-03  9:46 ` [PATCH 05/29] biultin/rev-parse: fix memory leaks in `--parseopt` mode Patrick Steinhardt
2024-06-03  9:46 ` [PATCH 06/29] merge-recursive: fix leaging rename conflict info Patrick Steinhardt
2024-06-06 10:07   ` Karthik Nayak
2024-06-03  9:46 ` [PATCH 07/29] revision: fix leaking display notes Patrick Steinhardt
2024-06-03  9:47 ` [PATCH 08/29] notes: fix memory leak when pruning notes Patrick Steinhardt
2024-06-03  9:47 ` [PATCH 09/29] builtin/rev-list: fix leaking bitmap index when calculating disk usage Patrick Steinhardt
2024-06-03  9:47 ` [PATCH 10/29] object-name: free leaking object contexts Patrick Steinhardt
2024-06-03  9:47 ` [PATCH 11/29] builtin/difftool: plug memory leaks in `run_dir_diff()` Patrick Steinhardt
2024-06-03  9:47 ` [PATCH 12/29] builtin/merge-recursive: fix leaking object ID bases Patrick Steinhardt
2024-06-03  9:47 ` [PATCH 13/29] merge-recursive: fix memory leak when finalizing merge Patrick Steinhardt
2024-06-06 10:50   ` Karthik Nayak
2024-06-06 15:52     ` Phillip Wood
2024-06-12  9:33       ` Karthik Nayak
2024-06-03  9:47 ` [PATCH 14/29] builtin/log: fix leaking commit list in git-cherry(1) Patrick Steinhardt
2024-06-03  9:47 ` [PATCH 15/29] revision: free diff options Patrick Steinhardt
2024-06-03  9:47 ` [PATCH 16/29] builtin/stash: fix leak in `show_stash()` Patrick Steinhardt
2024-06-03  9:47 ` [PATCH 17/29] rerere: fix various trivial leaks Patrick Steinhardt
2024-06-03  9:47 ` [PATCH 18/29] config: fix leaking "core.notesref" variable Patrick Steinhardt
2024-06-03  9:47 ` [PATCH 19/29] commit: fix leaking parents when calling `commit_tree_extended()` Patrick Steinhardt
2024-06-03  9:48 ` [PATCH 20/29] sequencer: fix leaking string buffer in `commit_staged_changes()` Patrick Steinhardt
2024-06-03 13:14   ` Phillip Wood
2024-06-04  6:45     ` Patrick Steinhardt
2024-06-04  7:19       ` Patrick Steinhardt
2024-06-04 13:58         ` Phillip Wood [this message]
2024-06-03  9:48 ` [PATCH 21/29] apply: fix leaking string in `match_fragment()` Patrick Steinhardt
2024-06-03  9:48 ` [PATCH 22/29] builtin/clone: plug leaking HEAD ref in `wanted_peer_refs()` Patrick Steinhardt
2024-06-03  9:48 ` [PATCH 23/29] sequencer: fix memory leaks in `make_script_with_merges()` Patrick Steinhardt
2024-06-03  9:48 ` [PATCH 24/29] builtin/merge: fix leaking `struct cmdnames` in `get_strategy()` Patrick Steinhardt
2024-06-03  9:48 ` [PATCH 25/29] merge: fix leaking merge bases Patrick Steinhardt
2024-06-03  9:48 ` [PATCH 26/29] line-range: plug leaking find functions Patrick Steinhardt
2024-06-03  9:48 ` [PATCH 27/29] blame: fix leaking data for blame scoreboards Patrick Steinhardt
2024-06-03  9:48 ` [PATCH 28/29] builtin/blame: fix leaking prefixed paths Patrick Steinhardt
2024-06-03  9:48 ` [PATCH 29/29] builtin/blame: fix leaking ignore revs files Patrick Steinhardt
2024-06-06 14:33 ` [PATCH 00/29] Memory leak fixes (pt.2) Karthik Nayak
2024-06-07  4:07   ` Patrick Steinhardt
2024-06-11  9:19 ` [PATCH v2 " Patrick Steinhardt
2024-06-11  9:19   ` [PATCH v2 01/29] revision: fix memory leak when reversing revisions Patrick Steinhardt
2024-06-11  9:19   ` [PATCH v2 02/29] parse-options: fix leaks for users of OPT_FILENAME Patrick Steinhardt
2024-06-11  9:19   ` [PATCH v2 03/29] notes-utils: free note trees when releasing copied notes Patrick Steinhardt
2024-06-11  9:19   ` [PATCH v2 04/29] bundle: plug leaks in `create_bundle()` Patrick Steinhardt
2024-06-11  9:19   ` [PATCH v2 05/29] biultin/rev-parse: fix memory leaks in `--parseopt` mode Patrick Steinhardt
2024-06-11  9:19   ` [PATCH v2 06/29] merge-recursive: fix leaking rename conflict info Patrick Steinhardt
2024-06-11  9:19   ` [PATCH v2 07/29] revision: fix leaking display notes Patrick Steinhardt
2024-06-11  9:19   ` [PATCH v2 08/29] notes: fix memory leak when pruning notes Patrick Steinhardt
2024-06-11  9:19   ` [PATCH v2 09/29] builtin/rev-list: fix leaking bitmap index when calculating disk usage Patrick Steinhardt
2024-06-11  9:19   ` [PATCH v2 10/29] object-name: free leaking object contexts Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 11/29] builtin/difftool: plug memory leaks in `run_dir_diff()` Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 12/29] builtin/merge-recursive: fix leaking object ID bases Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 13/29] merge-recursive: fix memory leak when finalizing merge Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 14/29] builtin/log: fix leaking commit list in git-cherry(1) Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 15/29] revision: free diff options Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 16/29] builtin/stash: fix leak in `show_stash()` Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 17/29] rerere: fix various trivial leaks Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 18/29] config: fix leaking "core.notesref" variable Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 19/29] commit: fix leaking parents when calling `commit_tree_extended()` Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 20/29] sequencer: fix leaking string buffer in `commit_staged_changes()` Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 21/29] apply: fix leaking string in `match_fragment()` Patrick Steinhardt
2024-06-11  9:20   ` [PATCH v2 22/29] builtin/clone: plug leaking HEAD ref in `wanted_peer_refs()` Patrick Steinhardt
2024-06-11  9:21   ` [PATCH v2 23/29] sequencer: fix memory leaks in `make_script_with_merges()` Patrick Steinhardt
2024-06-11  9:21   ` [PATCH v2 24/29] builtin/merge: fix leaking `struct cmdnames` in `get_strategy()` Patrick Steinhardt
2024-06-11  9:21   ` [PATCH v2 25/29] merge: fix leaking merge bases Patrick Steinhardt
2024-06-11  9:21   ` [PATCH v2 26/29] line-range: plug leaking find functions Patrick Steinhardt
2024-06-11  9:21   ` [PATCH v2 27/29] blame: fix leaking data for blame scoreboards Patrick Steinhardt
2024-06-11  9:21   ` [PATCH v2 28/29] builtin/blame: fix leaking prefixed paths Patrick Steinhardt
2024-06-11  9:21   ` [PATCH v2 29/29] builtin/blame: fix leaking ignore revs files Patrick Steinhardt
2024-06-12  9:09   ` [PATCH v2 00/29] Memory leak fixes (pt.2) Phillip Wood
2024-06-12  9:35   ` Karthik Nayak

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=396e6893-80d4-48f5-b43f-a30684a64bac@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@dunelm.org.uk \
    --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).