Re: [PATCH v4 0/5] rebase: cleanup merge strategy option handling
- From
Elijah Newren <newren@gmail.com>
- Date
- Apr 10, 2023, 16:46 UTC
- Message-ID
- <CABPp-BGUa_Aot_2iPmTWh1KvuL7mS4OSwXX-ArqgFSd8nU-+ig@mail.gmail.com>
- In-Reply-To
- <cover.1681117706.git.phillip.wood@dunelm.org.uk>
On Mon, Apr 10, 2023 at 2:08 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
Show 8 quoted lines
> > From: Phillip Wood <phillip.wood@dunelm.org.uk> > > Cleanup the handling of --strategy-option now that we no longer need to > support "--preserve-merges" and properly quote the argument when saving > it to disc. > > A hopefully final re-roll to fix a memory leak I spotted in V3.
Doh, I clearly missed that leak too.
Show 5 quoted lines
> Changes since V3: > - Fixed a memory leak added in V3. The array returned by > split_cmdline() is allocated on the heap so we need to fee it. The > array elements come from the string passed to split_cmdline() so do > not need to be individually freed.
And in particular, that string that stores those array elements will be freed by the strbuf_reset() that comes immediately after the read_strategy_opts() call (read_strategy_opts() is the sole caller of parse_strategy_opts()), and the fact that the string is freed is fine since your parse_strategy_opts() passes them to strvec_push() which will xstrdup() them and then own them.
All that to say I agree with the fix.