git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, "Hubert Jasudowicz" <hubertj@stmcyber.pl>,
	"Derrick Stolee" <derrickstolee@github.com>,
	"SZEDER Gábor" <szeder.dev@gmail.com>
Subject: Re: [PATCH] bundle: don't segfault on "git bundle <subcmd>"
Date: Sun, 25 Dec 2022 20:05:59 +0900	[thread overview]
Message-ID: <xmqq5ydzpwtk.fsf@gitster.g> (raw)
In-Reply-To: <patch-1.1-2319eb2ddbd-20221220T133941Z-avarab@gmail.com> ("Ævar	Arnfjörð Bjarmason"'s message of "Tue, 20 Dec 2022 14:40:18 +0100")

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> As an aside, this could be safely squashed into this, but let's not do
> that for this minimal segfault fix, as it's an unrelated refactoring:
>
> 	--- a/builtin/bundle.c
> 	+++ b/builtin/bundle.c
> 	@@ -55,13 +55,12 @@ static int parse_options_cmd_bundle(int argc,
> 	 		const char * const usagestr[],
> 	 		const struct option options[],
> 	 		char **bundle_file) {
> 	-	int newargc;
> 	-	newargc = parse_options(argc, argv, NULL, options, usagestr,
> 	+	argc = parse_options(argc, argv, NULL, options, usagestr,
> 	 			     PARSE_OPT_STOP_AT_NON_OPTION);
> 	-	if (!newargc)
> 	+	if (!argc)
> 	 		usage_with_options(usagestr, options);
> 	 	*bundle_file = prefix_filename(prefix, argv[0]);
> 	-	return newargc;
> 	+	return argc;
> 	 }

That would actually make the intent much clearer and if the code
were written to update argc instead of introducing a separate
varilable, this bug would not have happened.

Thanks, will queue (without the clean-up at least for now).

  parent reply	other threads:[~2022-12-25 11:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-20 12:31 [PATCH] Revert "builtin/bundle.c: let parse-options parse subcommands" Hubert Jasudowicz
2022-12-20 13:30 ` Derrick Stolee
2022-12-20 13:42   ` Ævar Arnfjörð Bjarmason
2022-12-20 13:40 ` [PATCH] bundle: don't segfault on "git bundle <subcmd>" Ævar Arnfjörð Bjarmason
2022-12-20 13:50   ` Hubert Jasudowicz
2022-12-25 11:06     ` Junio C Hamano
2022-12-25 11:05   ` Junio C Hamano [this message]
2022-12-27 18:39     ` [PATCH 0/2] builtin/bundle.c: segfault fix style & error reporting follow-up Ævar Arnfjörð Bjarmason
2022-12-27 18:39       ` [PATCH 1/2] builtin/bundle.c: remove superfluous "newargc" variable Ævar Arnfjörð Bjarmason
2022-12-27 18:39       ` [PATCH 2/2] bundle <cmd>: have usage_msg_opt() note the missing "<file>" Ævar Arnfjörð Bjarmason
2022-12-27 23:32       ` [PATCH 0/2] builtin/bundle.c: segfault fix style & error reporting follow-up Junio C Hamano

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=xmqq5ydzpwtk.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=hubertj@stmcyber.pl \
    --cc=szeder.dev@gmail.com \
    /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).