Re: [GSoC][PATCH 1/1] rebase -i: add --ignore-whitespace flag
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 15, 2019, 22:08 UTC
- Message-ID
- <xmqqd0ib3q8x.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20190715220010.8146-1-rohit.ashiwal265@gmail.com>
Rohit Ashiwal <rohit.ashiwal265@gmail.com> writes:
Show 19 quoted lines
> Hi Junio
>
> On Mon, 15 Jul 2019 10:57:18 -0700 Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Rohit Ashiwal <rohit.ashiwal265@gmail.com> writes:
>>
>> > + if (opts->ignore_whitespace) {
>> > + struct strbuf buf = STRBUF_INIT;
>> > +
>> > + if (opts->strategy_opts)
>> > + strbuf_addstr(&buf, opts->strategy_opts);
>> > +
>> > + strbuf_addstr(&buf, " --ignore-space-change");
>> > + free(opts->strategy_opts);
>>
>> Is this call to free() safe?
>
> Yes, as far as I can tell. Since up till now, `strategy_opts` is
> either "NULL" or xstrdup()'d string. There is no double free involved.Doesn't it also come from handling OPT_STRING() via parse_options(), which gives a pointer from argv[], freeing something that is not allocated in the first place?