diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2023-02-07 00:07:40 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-02-06 15:34:37 -0800 |
commit | 7615cf94d2af0f9ae71c4302092990e635f23a8f (patch) | |
tree | 5710f3628f1ff99bef13437444ccf68f3a2eb834 /builtin/stash.c | |
parent | 81e5c39cf63b414468adcc6601184212e68e1fc1 (diff) | |
download | git-7615cf94d2af0f9ae71c4302092990e635f23a8f.tar.gz |
various: add missing clear_pathspec(), fix leaks
Fix memory leaks resulting from a missing clear_pathspec().
- archive.c: Plug a leak in the "struct archiver_args", and
clear_pathspec() the "pathspec" member that the "parse_pathspec_arg()"
call in this function populates.
- builtin/clean.c: Fix a memory leak that's been with us since
893d839970c (clean: convert to use parse_pathspec, 2013-07-14).
- builtin/reset.c: Add clear_pathspec() calls to cmd_reset(),
including to the codepaths where we'd return early.
- builtin/stash.c: Call clear_pathspec() on the pathspec initialized
in push_stash().
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/stash.c')
-rw-r--r-- | builtin/stash.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin/stash.c b/builtin/stash.c index 839569a980..71a4ee6b1a 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1727,6 +1727,7 @@ static int push_stash(int argc, const char **argv, const char *prefix, OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul), OPT_END() }; + int ret; if (argc) { force_assume = !strcmp(argv[0], "-p"); @@ -1766,8 +1767,10 @@ static int push_stash(int argc, const char **argv, const char *prefix, die(_("the option '%s' requires '%s'"), "--pathspec-file-nul", "--pathspec-from-file"); } - return do_push_stash(&ps, stash_msg, quiet, keep_index, patch_mode, - include_untracked, only_staged); + ret = do_push_stash(&ps, stash_msg, quiet, keep_index, patch_mode, + include_untracked, only_staged); + clear_pathspec(&ps); + return ret; } static int push_stash_unassumed(int argc, const char **argv, const char *prefix) |