From: Phillip Wood Date: Fri, 04 Nov 2022 14:50:02 GMT Subject: Re: [PATCH 10/17] sequencer.c: fix "opts->strategy" leak in read_strategy_opts() Message-ID: In-Reply-To: On 03/11/2022 17:06, Ævar Arnfjörð Bjarmason wrote: > When "read_strategy_opts()" is called we may have populated the > "opts->strategy" before, so we'll need to free() it to avoid leaking > memory. Where is the previous value coming from? I guess it may be the config but otherwise I'm confused. > Along with the preceding commit this change various > rebase-related tests pass. Really? at a glance the previous patch looks unrelated and there are no tests marked as passing in this one. Best Wishes Phillip > Signed-off-by: Ævar Arnfjörð Bjarmason > --- > sequencer.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/sequencer.c b/sequencer.c > index e658df7e8ff..07d7062bfb8 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -2894,6 +2894,7 @@ static void read_strategy_opts(struct replay_opts *opts, struct strbuf *buf) > strbuf_reset(buf); > if (!read_oneliner(buf, rebase_path_strategy(), 0)) > return; > + free(opts->strategy); > opts->strategy = strbuf_detach(buf, NULL); > if (!read_oneliner(buf, rebase_path_strategy_opts(), 0)) > return;