summaryrefslogtreecommitdiff
path: root/builtin-ls-files.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin-ls-files.c')
-rw-r--r--builtin-ls-files.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 6c1db86e80..48dd3f77a4 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -299,7 +299,6 @@ static void prune_cache(const char *prefix)
static const char *verify_pathspec(const char *prefix)
{
const char **p, *n, *prev;
- char *real_prefix;
unsigned long max;
prev = NULL;
@@ -326,14 +325,8 @@ static const char *verify_pathspec(const char *prefix)
if (prefix_offset > max || memcmp(prev, prefix, prefix_offset))
die("git-ls-files: cannot generate relative filenames containing '..'");
- real_prefix = NULL;
prefix_len = max;
- if (max) {
- real_prefix = xmalloc(max + 1);
- memcpy(real_prefix, prev, max);
- real_prefix[max] = 0;
- }
- return real_prefix;
+ return max ? xmemdupz(prev, max) : NULL;
}
/*