Skip to content

Commit

Permalink
add-patch: plug a leak handling the '/' command
Browse files Browse the repository at this point in the history
Plug a leak we have since d6cf873 (built-in add -p: implement the '/'
("search regex") command, 2019-12-13).

This leak can be triggered with:

    $ printf "A\n\nB\n" >file
    $ git add file && git commit -m file
    $ printf "AA\n\nBB\n" >file
    $ printf "s\n/ .\n" >lines
    $ git add -p <lines

Signed-off-by: Rubén Justo <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
rjusto authored and gitster committed Apr 22, 2024
1 parent 5861aa8 commit ec9b74b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions add-patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,7 @@ static int patch_update_file(struct add_p_state *s,
err(s, _("No hunk matches the given pattern"));
break;
}
regfree(&regex);
hunk_index = i;
} else if (s->answer.buf[0] == 's') {
size_t splittable_into = hunk->splittable_into;
Expand Down

0 comments on commit ec9b74b

Please sign in to comment.