Skip to content

Commit 1c3e412

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 898f807 commit 1c3e412

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

archive.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
662662
rc = ar->write_archive(ar, &args);
663663

664664
string_list_clear_func(&args.extra_files, extra_file_info_clear);
665+
free(args.refname);
665666

666667
return rc;
667668
}

archive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct repository;
88

99
struct archiver_args {
1010
struct repository *repo;
11-
const char *refname;
11+
char *refname;
1212
const char *prefix;
1313
const char *base;
1414
size_t baselen;

0 commit comments

Comments
 (0)