Skip to content

Commit 92a5d1c

Browse files
committed
hash-object: prefix_filename() returns allocated memory these days
Back when a1be47e (hash-object: fix buffer reuse with --path in a subdirectory, 2017-03-20) was written, the prefix_filename() helper used a static piece of memory to the caller, making the caller responsible for copying it, if it wants to keep it across another call to the same function. Two callers of the prefix_filename() in hash-object were made to xstrdup() the value obtained from it. But in the same series, when e4da43b (prefix_filename: return newly allocated string, 2017-03-20) changed the rule to gave the caller possession of the memory, we forgot to revert one of the xstrdup() changes, allowing the returned value to leak. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 225bc32 commit 92a5d1c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/hash-object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
117117
prefix = setup_git_directory_gently(&nongit);
118118

119119
if (vpath && prefix)
120-
vpath = xstrdup(prefix_filename(prefix, vpath));
120+
vpath = prefix_filename(prefix, vpath);
121121

122122
git_config(git_default_config, NULL);
123123

0 commit comments

Comments
 (0)