]> git.ipfire.org Git - thirdparty/git.git/commitdiff
archive: release refname after use
authorRené Scharfe <l.s.r@web.de>
Sat, 14 Nov 2020 22:01:04 +0000 (23:01 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Nov 2020 22:21:43 +0000 (14:21 -0800)
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>
archive.c
archive.h

index 3c1541af9e2dfbb9189890beee745bc8574f82fe..da89d292c291f4e6e8aaae6a3899ed95d92e5ba9 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -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;
 }
index 82b226011abb60e017cba0bcda355f1a6af6aa5e..43028ffbf37fa14e68a5458c2238f3c479d48d27 100644 (file)
--- a/archive.h
+++ b/archive.h
@@ -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;