mirror of
https://github.com/git/git.git
synced 2024-10-28 12:59:41 +01:00
sequencer: stop leaking buf
In read_populate_opts(), we call read_oneliner() _after_ calling strbuf_release(). This means that `buf` is leaked at the end of the function. Always clean up the strbuf by going to `done_rebase_i` whether or not we return an error. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
fd6852cab2
commit
65c425a2ec
1 changed files with 9 additions and 4 deletions
13
sequencer.c
13
sequencer.c
|
@ -2485,6 +2485,7 @@ static int read_populate_opts(struct replay_opts *opts)
|
||||||
{
|
{
|
||||||
if (is_rebase_i(opts)) {
|
if (is_rebase_i(opts)) {
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (read_oneliner(&buf, rebase_path_gpg_sign_opt(), 1)) {
|
if (read_oneliner(&buf, rebase_path_gpg_sign_opt(), 1)) {
|
||||||
if (!starts_with(buf.buf, "-S"))
|
if (!starts_with(buf.buf, "-S"))
|
||||||
|
@ -2525,7 +2526,7 @@ static int read_populate_opts(struct replay_opts *opts)
|
||||||
opts->keep_redundant_commits = 1;
|
opts->keep_redundant_commits = 1;
|
||||||
|
|
||||||
read_strategy_opts(opts, &buf);
|
read_strategy_opts(opts, &buf);
|
||||||
strbuf_release(&buf);
|
strbuf_reset(&buf);
|
||||||
|
|
||||||
if (read_oneliner(&opts->current_fixups,
|
if (read_oneliner(&opts->current_fixups,
|
||||||
rebase_path_current_fixups(), 1)) {
|
rebase_path_current_fixups(), 1)) {
|
||||||
|
@ -2538,12 +2539,16 @@ static int read_populate_opts(struct replay_opts *opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_oneliner(&buf, rebase_path_squash_onto(), 0)) {
|
if (read_oneliner(&buf, rebase_path_squash_onto(), 0)) {
|
||||||
if (get_oid_hex(buf.buf, &opts->squash_onto) < 0)
|
if (get_oid_hex(buf.buf, &opts->squash_onto) < 0) {
|
||||||
return error(_("unusable squash-onto"));
|
ret = error(_("unusable squash-onto"));
|
||||||
|
goto done_rebase_i;
|
||||||
|
}
|
||||||
opts->have_squash_onto = 1;
|
opts->have_squash_onto = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
done_rebase_i:
|
||||||
|
strbuf_release(&buf);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists(git_path_opts_file()))
|
if (!file_exists(git_path_opts_file()))
|
||||||
|
|
Loading…
Reference in a new issue