archive: release refname after use

parse_treeish_arg() uses dwim_ref() to set refname to a strdup'd string.
Release it after use.  Also remove the const qualifier from the refname
member to signify that ownership of the string is handed to the struct,
leaving cleanup duty with the caller of parse_treeish_arg(), thus
avoiding a cast.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2020-11-14 23:01:04 +01:00 committed by Junio C Hamano
parent 898f80736c
commit 1c3e412916
2 changed files with 2 additions and 1 deletions

View File

@ -662,6 +662,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
rc = ar->write_archive(ar, &args);
string_list_clear_func(&args.extra_files, extra_file_info_clear);
free(args.refname);
return rc;
}

View File

@ -8,7 +8,7 @@ struct repository;
struct archiver_args {
struct repository *repo;
const char *refname;
char *refname;
const char *prefix;
const char *base;
size_t baselen;