]> Kevux Git Server - rit/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 3c1541a..da89d29 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 82b2260..43028ff 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;