Skip to content

Commit

Permalink
archive: release refname after use
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rscharfe authored and gitster committed Nov 16, 2020
1 parent 898f807 commit 1c3e412
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1c3e412

Please sign in to comment.