builtin-fsck: reports missing parent commits
[gitweb.git] / builtin-clean.c
index 6cad8eaf2591c8f7f04c78f5a2162808ae702e25..eb853a37cf993a875f2acd1992ee5191783740a1 100644 (file)
@@ -90,7 +90,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
        strbuf_init(&directory, 0);
 
        if (pathspec)
-               seen = xmalloc(argc);
+               seen = xmalloc(argc > 0 ? argc : 1);
 
        for (i = 0; i < dir.nr; i++) {
                struct dir_entry *ent = dir.entries[i];
@@ -125,7 +125,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                        continue;
 
                if (pathspec) {
-                       memset(seen, 0, argc);
+                       memset(seen, 0, argc > 0 ? argc : 1);
                        matches = match_pathspec(pathspec, ent->name, ent->len,
                                                 baselen, seen);
                } else {