[PATCH 10/17] sequencer.c: fix "opts->strategy" leak in read_strategy_opts()
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Nov 3, 2022, 17:06 UTC
- Message-ID
- <patch-10.17-9c70bfa334e-20221103T164632Z-avarab@gmail.com>
- In-Reply-To
- <cover-00.17-00000000000-20221103T164632Z-avarab@gmail.com>
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. Along with the preceding commit this change various rebase-related tests pass.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- 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;
-- 2.38.0.1451.g86b35f4140a