diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-10-01 20:05:10 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-10-01 20:05:10 +0000 |
| commit | c5bd4620b0a6f37ceb44e004eceda1a708585e5b (patch) | |
| tree | a620327a53a0cdd79aab700af6c405d345b81f4e | |
| parent | 8de197ce04e80b67054dfeae7ee4892d0173fd0f (diff) | |
lib: Fix command execution npe
Caller may pass NULL if it does not care about what
command was matched.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
| -rw-r--r-- | lib/command.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/command.c b/lib/command.c index a74e967c94..9d68f33989 100644 --- a/lib/command.c +++ b/lib/command.c @@ -698,8 +698,13 @@ cmd_execute_command_real (vector vline, { struct list *argv_list; enum matcher_rv status; + struct cmd_element *matched_element = NULL; + struct graph *cmdgraph = cmd_node_graph (cmdvec, vty->node); - status = command_match (cmdgraph, vline, &argv_list, cmd); + status = command_match (cmdgraph, vline, &argv_list, &matched_element); + + if (cmd) + *cmd = matched_element; // if matcher error, return corresponding CMD_ERR if (MATCHER_ERROR(status)) @@ -724,10 +729,10 @@ cmd_execute_command_real (vector vline, int argc = argv_list->count; int ret; - if ((*cmd)->daemon) + if (matched_element->daemon) ret = CMD_SUCCESS_DAEMON; else - ret = (*cmd)->func (*cmd, vty, argc, argv); + ret = matched_element->func (matched_element, vty, argc, argv); // delete list and cmd_token's in it list_delete (argv_list); |
