History

new_filter: correctly initialise all arguments for a new filter

Ferry Huberts committed 15 years ago

Commit 5db02851 parent 3f1ebd31 file · +4 −2Browse files

Unified · Split

cgit.c+4−2
@@ -29,15 +29,17 @@ void add_mimetype(const char *name, const char *value) · 28 unmodified lines
2929 struct cgit_filter *new_filter(const char *cmd, int extra_args)
3030 {
3131 struct cgit_filter *f;
32+ int args_size = 0;
3233
3334 if (!cmd || !cmd[0])
3435 return NULL;
3536
3637 f = xmalloc(sizeof(struct cgit_filter));
3738 f->cmd = xstrdup(cmd);
38− f->argv = xmalloc((2 + extra_args) * sizeof(char *));
39+ args_size = (2 + extra_args) * sizeof(char *);
40+ f->argv = xmalloc(args_size);
41+ memset(f->argv, 0, args_size);
3942 f->argv[0] = f->cmd;
40− f->argv[1] = NULL;
4143 return f;
4244 }
4345

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t