Re: [ANNOUNCE] GIT 1.5.4-rc3
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 12, 2008, 16:57 UTC
- Message-ID
- <alpine.LSU.1.00.0801121756400.8333@wbgn129.biozentrum.uni-wuerzburg.de>
- In-Reply-To
- <20080112090432.GA6134@coredump.intra.peff.net>
Hi,
On Sat, 12 Jan 2008, Jeff King wrote:
Show 22 quoted lines
> diff --git a/builtin-clean.c b/builtin-clean.c
> index 6cad8ea..eb853a3 100644
> --- a/builtin-clean.c
> +++ b/builtin-clean.c
> @@ -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 {Would it not be better to guard the memset by an "if (argc)", and set "seen" to NULL by default?
Ciao, Dscho