]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-ls-files.c
Use xmemdupz() in many places.
[git.git] / builtin-ls-files.c
index 6c1db86e8056285cb25359d55f5ebf9dd0e6f489..48dd3f77a4157c6f9f7e52e9e9884faa06568955 100644 (file)
@@ -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;
 }
 
 /*