Re: [PATCH v2 1/9] rebase -i: generate the script via rebase--helper
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Apr 26, 2017, 11:34 UTC
- Message-ID
- <alpine.DEB.2.20.1704261333480.3480@virtualbox>
- In-Reply-To
- <20170426104511.nuk3fcxofhrtxsma@sigill.intra.peff.net>
Hi Peff,
On Wed, 26 Apr 2017, Jeff King wrote:
Show 22 quoted lines
> On Tue, Apr 25, 2017 at 03:51:49PM +0200, Johannes Schindelin wrote:
>
> > --- a/sequencer.c
> > +++ b/sequencer.c
> > [...]
> > +int sequencer_make_script(int keep_empty, FILE *out,
> > + int argc, const char **argv)
> > +{
> > + char *format = "%s";
>
> I'm surprised the compiler doesn't complain about assigning a string
> literal to a non-const pointer. It makes me worried that we would call
> free() on it later. We don't, but that means...
>
> > + git_config_get_string("rebase.instructionFormat", &format);
>
> ...that this assignment to "format" leaks.
>
> So perhaps you'd want to xstrdup the literal, and then make sure the
> result is freed? Or alternatively use an extra level of indirection (a
> to_free pointer to store the config value, and then a const pointer for
> "format").Good suggestion. Will be part of v3, Dscho