diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-02-18 13:53:29 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-02-18 13:53:29 -0800 |
commit | 09320a8af1b54b5953de9646250e0d1f7da0cc4b (patch) | |
tree | 7eda650f406db2275665361f6c53883e0c21b5f3 /builtin/hash-object.c | |
parent | Merge branch 'gc/branch-recurse-submodules' (diff) | |
parent | hash-object: fix a trivial leak in --path (diff) | |
download | tgif-09320a8af1b54b5953de9646250e0d1f7da0cc4b.tar.xz |
Merge branch 'ab/hash-object-leakfix'
Trivial leakfix.
* ab/hash-object-leakfix:
hash-object: fix a trivial leak in --path
Diffstat (limited to 'builtin/hash-object.c')
-rw-r--r-- | builtin/hash-object.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/builtin/hash-object.c b/builtin/hash-object.c index c7b3ad74c6..db9b253527 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -92,6 +92,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix) int nongit = 0; unsigned flags = HASH_FORMAT_CHECK; const char *vpath = NULL; + char *vpath_free = NULL; const struct option hash_object_options[] = { OPT_STRING('t', NULL, &type, N_("type"), N_("object type")), OPT_BIT('w', NULL, &flags, N_("write the object into the object database"), @@ -114,8 +115,10 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix) else prefix = setup_git_directory_gently(&nongit); - if (vpath && prefix) - vpath = prefix_filename(prefix, vpath); + if (vpath && prefix) { + vpath_free = prefix_filename(prefix, vpath); + vpath = vpath_free; + } git_config(git_default_config, NULL); @@ -156,5 +159,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix) if (stdin_paths) hash_stdin_paths(type, no_filters, flags, literally); + free(vpath_free); + return 0; } |