Re: [PATCH v2 1/9] rebase -i: generate the script via rebase--helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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").

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]