mirror of
https://git.zx2c4.com/cgit/
synced 2024-11-13 19:12:05 +00:00
new_filter: correctly initialise all arguments for a new filter
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This commit is contained in:
parent
3f1ebd3565
commit
5db02854e6
6
cgit.c
6
cgit.c
@ -29,15 +29,17 @@ void add_mimetype(const char *name, const char *value)
|
|||||||
struct cgit_filter *new_filter(const char *cmd, int extra_args)
|
struct cgit_filter *new_filter(const char *cmd, int extra_args)
|
||||||
{
|
{
|
||||||
struct cgit_filter *f;
|
struct cgit_filter *f;
|
||||||
|
int args_size = 0;
|
||||||
|
|
||||||
if (!cmd || !cmd[0])
|
if (!cmd || !cmd[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
f = xmalloc(sizeof(struct cgit_filter));
|
f = xmalloc(sizeof(struct cgit_filter));
|
||||||
f->cmd = xstrdup(cmd);
|
f->cmd = xstrdup(cmd);
|
||||||
f->argv = xmalloc((2 + extra_args) * sizeof(char *));
|
args_size = (2 + extra_args) * sizeof(char *);
|
||||||
|
f->argv = xmalloc(args_size);
|
||||||
|
memset(f->argv, 0, args_size);
|
||||||
f->argv[0] = f->cmd;
|
f->argv[0] = f->cmd;
|
||||||
f->argv[1] = NULL;
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user