aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/stash.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-08-24 14:54:33 -0700
committerJunio C Hamano <gitster@pobox.com>2020-08-24 14:54:34 -0700
commitad00f44f5479441da59bd55261ae717fcb357938 (patch)
tree68f77a1bfd9deb6b5a88b937e27ab5e5b7400e59 /builtin/stash.c
parent51226147d16d59243957cb3bc1b2313f9f740725 (diff)
parenteceba5321410bbcc9e0b11e6aa479832f574eca8 (diff)
downloadgit-ad00f44f5479441da59bd55261ae717fcb357938.tar.gz
Merge branch 'en/dir-clear'
Leakfix with code clean-up. * en/dir-clear: dir: fix problematic API to avoid memory leaks dir: make clear_directory() free all relevant memory
Diffstat (limited to 'builtin/stash.c')
-rw-r--r--builtin/stash.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/builtin/stash.c b/builtin/stash.c
index 10d87630cd..4bdfaf8397 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -864,7 +864,7 @@ static int get_untracked_files(const struct pathspec *ps, int include_untracked,
int found = 0;
struct dir_struct dir;
- memset(&dir, 0, sizeof(dir));
+ dir_init(&dir);
if (include_untracked != INCLUDE_ALL_FILES)
setup_standard_excludes(&dir);
@@ -875,12 +875,9 @@ static int get_untracked_files(const struct pathspec *ps, int include_untracked,
strbuf_addstr(untracked_files, ent->name);
/* NUL-terminate: will be fed to update-index -z */
strbuf_addch(untracked_files, '\0');
- free(ent);
}
- free(dir.entries);
- free(dir.ignored);
- clear_directory(&dir);
+ dir_clear(&dir);
return found;
}