Merge branch 'ab/hash-object-leakfix'
Trivial leakfix. * ab/hash-object-leakfix: hash-object: fix a trivial leak in --path
This commit is contained in:
commit
09320a8af1
@ -92,6 +92,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
|
|||||||
int nongit = 0;
|
int nongit = 0;
|
||||||
unsigned flags = HASH_FORMAT_CHECK;
|
unsigned flags = HASH_FORMAT_CHECK;
|
||||||
const char *vpath = NULL;
|
const char *vpath = NULL;
|
||||||
|
char *vpath_free = NULL;
|
||||||
const struct option hash_object_options[] = {
|
const struct option hash_object_options[] = {
|
||||||
OPT_STRING('t', NULL, &type, N_("type"), N_("object type")),
|
OPT_STRING('t', NULL, &type, N_("type"), N_("object type")),
|
||||||
OPT_BIT('w', NULL, &flags, N_("write the object into the object database"),
|
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
|
else
|
||||||
prefix = setup_git_directory_gently(&nongit);
|
prefix = setup_git_directory_gently(&nongit);
|
||||||
|
|
||||||
if (vpath && prefix)
|
if (vpath && prefix) {
|
||||||
vpath = prefix_filename(prefix, vpath);
|
vpath_free = prefix_filename(prefix, vpath);
|
||||||
|
vpath = vpath_free;
|
||||||
|
}
|
||||||
|
|
||||||
git_config(git_default_config, NULL);
|
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)
|
if (stdin_paths)
|
||||||
hash_stdin_paths(type, no_filters, flags, literally);
|
hash_stdin_paths(type, no_filters, flags, literally);
|
||||||
|
|
||||||
|
free(vpath_free);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
test_description="git hash-object"
|
test_description="git hash-object"
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
echo_without_newline() {
|
echo_without_newline() {
|
||||||
|
Loading…
Reference in New Issue
Block a user