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>
This commit is contained in:
committed by
Junio C Hamano
parent
56931c4d89
commit
14da26230a
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user