commit f86a1bf597011ffe7c93e485ee9c2a919df2e383 from: Stefan Sperling date: Sat Jul 27 09:35:26 2019 UTC plug memleaks of paths on pathlist in cmd_status() commit - 09ea71bad2befccc590048e27bc32911faa5c158 commit + f86a1bf597011ffe7c93e485ee9c2a919df2e383 blob - 5d3cf66c9beb5bfe01e92ef6314d49a14c3b4870 blob + d574925b364729e6dcdcfa7e17faadd5ef78431c --- got/got.c +++ got/got.c @@ -2318,7 +2318,7 @@ cmd_status(int argc, char *argv[]) const struct got_error *error = NULL; struct got_repository *repo = NULL; struct got_worktree *worktree = NULL; - char *cwd = NULL, *path = NULL; + char *cwd = NULL; struct got_pathlist_head paths; int ch, i; @@ -2356,6 +2356,7 @@ cmd_status(int argc, char *argv[]) goto done; } else if (argc >= 1) { for (i = 0; i < argc; i++) { + char *path; error = got_worktree_resolve_path(&path, worktree, argv[i]); if (error) @@ -2381,9 +2382,13 @@ cmd_status(int argc, char *argv[]) error = got_worktree_status(worktree, &paths, repo, print_status, NULL, check_cancelled, NULL); done: + if (argc >= 1) { + struct got_pathlist_entry *pe; + TAILQ_FOREACH(pe, &paths, entry) + free((char *)pe->path); + } got_pathlist_free(&paths); free(cwd); - free(path); return error; }