[ccan] [PATCH 10/10] tools: avoid needless post increment on size

Brad Hards bradh at frogmouth.net
Tue Mar 8 20:28:13 EST 2011


Also add a note about a possible segfault.
---
 tools/namespacize.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/tools/namespacize.c b/tools/namespacize.c
index 5ac85f5..cf6bc26 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;
 }
-- 
1.7.1



More information about the ccan mailing list