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>
René Scharfe committed
Nov 14, 2020 at 23:01 UTC
1c3e412916df1193b270a6947782f96524e5fa45
2 files changed
+2
-1
archive.c
+1
@@ -662,6 +662,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
662
rc = ar->write_archive(ar, &args);
663
664
string_list_clear_func(&args.extra_files, extra_file_info_clear);
665
+ free(args.refname);
666
667
return rc;
668
}
archive.h
+1
-1
@@ -8,7 +8,7 @@ struct repository;
8
9
struct archiver_args {
10
struct repository *repo;
11
- const char *refname;
11
+ char *refname;
12
const char *prefix;
13
const char *base;
14
size_t baselen;