aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/archive.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-06-11 11:19:22 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-11 13:15:04 -0700
commit14da26230a7644a2f9dfbc3f43d9d7ab6e0074e9 (patch)
tree600341b6864236888a6508a79bf46e97436ded8b /builtin/archive.c
parent56931c4d89e7efe41dd96d230b8176e2d32a035d (diff)
downloadgit-14da26230a7644a2f9dfbc3f43d9d7ab6e0074e9.tar.gz
parse-options: fix leaks for users of OPT_FILENAME
The `OPT_FILENAME()` option will, if set, put an allocated string into the user-provided variable. Consequently, that variable thus needs to be free'd by the caller of `parse_options()`. Some callsites don't though and thus leak memory. Fix those. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/archive.c')
-rw-r--r--builtin/archive.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin/archive.c b/builtin/archive.c
index 15ee1ec7bb..f29c0ef6ad 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -92,6 +92,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
N_("path to the remote git-upload-archive command")),
OPT_END()
};
+ int ret;
argc = parse_options(argc, argv, prefix, local_opts, NULL,
PARSE_OPT_KEEP_ALL);
@@ -106,6 +107,8 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
- UNLEAK(output);
- return write_archive(argc, argv, prefix, the_repository, output, 0);
+ ret = write_archive(argc, argv, prefix, the_repository, output, 0);
+
+ free(output);
+ return ret;
}