Re: [ANNOUNCE] GIT 1.5.4-rc3

From
Johannes Schindelin <hidden>
Date
2016-06-15 22:44:04
Reply to
Jeff King, 2016-06-15
Hi,

On Sat, 12 Jan 2008, Jeff King wrote:
quoted hunk ↗ jump to hunk
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
Thread (12 messages) 12 messages, 5 authors, last reply 2016-06-15
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help