Thread (11 messages) flat view 11 messages, 2 authors, 2016-06-15

[CGit] [PATCH 2/6] new_filter: correctly initialise all arguments for a new filter

From: Ferry Huberts <hidden>
Date: 2016-06-15 22:50:35
Subsystem: the rest · Maintainer: Linus Torvalds

From: Ferry Huberts <redacted>

Signed-off-by: Ferry Huberts <redacted>
---
 cgit.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/cgit.c b/cgit.c
index 412fbf0..4440feb 100644
--- a/cgit.c
+++ b/cgit.c
@@ -28,6 +28,7 @@ void add_mimetype(const char *name, const char *value)
 
 struct cgit_filter *new_filter(const char *cmd, int extra_args)
 {
+	int i = 0;
 	struct cgit_filter *f;
 
 	if (!cmd || !cmd[0])
@@ -36,8 +37,10 @@ struct cgit_filter *new_filter(const char *cmd, int extra_args)
 	f = xmalloc(sizeof(struct cgit_filter));
 	f->cmd = xstrdup(cmd);
 	f->argv = xmalloc((2 + extra_args) * sizeof(char *));
-	f->argv[0] = f->cmd;
-	f->argv[1] = NULL;
+	f->argv[i++] = f->cmd;
+	while (i < (2 + extra_args)) {
+	  f->argv[i++] = NULL;
+	}
 	return f;
 }
 
-- 
1.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help