system/corennnnn
Revisão | 3649e2500445e03aca631f3bb381acbfc0239e8e (tree) |
---|---|
Hora | 2011-08-04 17:36:35 |
Autor | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
init: make sure the last parameter to execve is NULL
Extend the buffer to hold one more pointer, and set it is NULL.
Change-Id: I3018d62a1b0d61c0a3f5f2f7ffa12c7ce9ee32c5
@@ -662,7 +662,12 @@ static void parse_line_action(struct parse_state* state, int nargs, char **args) | ||
662 | 662 | n > 2 ? "arguments" : "argument"); |
663 | 663 | return; |
664 | 664 | } |
665 | - cmd = malloc(sizeof(*cmd) + sizeof(char*) * nargs); | |
665 | + cmd = calloc(1, sizeof(*cmd) + sizeof(char*) * (nargs + 1)); | |
666 | + if (!cmd) { | |
667 | + parse_error(state, "malloc failed\n"); | |
668 | + return; | |
669 | + } | |
670 | + | |
666 | 671 | cmd->func = kw_func(kw); |
667 | 672 | cmd->nargs = nargs; |
668 | 673 | memcpy(cmd->args, args, sizeof(char*) * nargs); |