Merge branch 'ab/grep-plug-pathspec-leak'
[gitweb.git] / builtin / ls-remote.c
index 66cdd45cc10afd37f93f260688700408d11b1f5f..b2d7d5ce6841cf9cb9e310c659aac043ad00cfb0 100644 (file)
@@ -17,17 +17,19 @@ static const char * const ls_remote_usage[] = {
 static int tail_match(const char **pattern, const char *path)
 {
        const char *p;
-       char pathbuf[PATH_MAX];
+       char *pathbuf;
 
        if (!pattern)
                return 1; /* no restriction */
 
-       if (snprintf(pathbuf, sizeof(pathbuf), "/%s", path) > sizeof(pathbuf))
-               return error("insanely long ref %.*s...", 20, path);
+       pathbuf = xstrfmt("/%s", path);
        while ((p = *(pattern++)) != NULL) {
-               if (!wildmatch(p, pathbuf, 0, NULL))
+               if (!wildmatch(p, pathbuf, 0, NULL)) {
+                       free(pathbuf);
                        return 1;
+               }
        }
+       free(pathbuf);
        return 0;
 }