[CGit] [PATCH v2 2/6] new_filter: correctly initialise all arguments for a new filter
Lars Hjemli
hjemli at gmail.com
Sun Mar 6 15:44:46 CET 2011
On Fri, Mar 4, 2011 at 01:31, Ferry Huberts <mailings at hupie.com> wrote:
> @@ -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;
> }
Maybe something like this instead?
size = (2 + extra_args) * sizeof(char *);
f->argv = xmalloc(size);
memset(argv, 0, size);
--
larsh
More information about the CGit
mailing list