From: Brad Hards Date: Tue, 8 Mar 2011 09:28:13 +0000 (+1100) Subject: tools: avoid needless post increment on size X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=c6bbde3a1b508d6cbb417ee99d64e4fbd09c865c tools: avoid needless post increment on size Also add a note about a possible segfault. --- diff --git a/tools/namespacize.c b/tools/namespacize.c index 5ac85f50..cf6bc26d 100644 --- a/tools/namespacize.c +++ b/tools/namespacize.c @@ -53,7 +53,8 @@ static char **get_dir(const char *dir) names[size++] = talloc_asprintf(names, "%s/%s", dir, ent->d_name); } - names[size++] = NULL; + /* FIXME: if the loop doesn't run at least once, we'll segfault here */ + names[size] = NULL; closedir(d); return names; }