diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-08-09 17:37:01 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-08-09 17:37:01 +0000 |
| commit | 4427e9b3eeb6aaff3882dd1e96e14af62fa37ad4 (patch) | |
| tree | 1cb9919bd6e5b661f8b6900b2510109319ec0e68 /lib/grammar_sandbox.c | |
| parent | 1ab84bf32f891c9aa62e1d2a42501a0df7d6aec0 (diff) | |
lib: Fix various minor bugs
- cmd_make_strvec returns null pointer if str
begins with a '#'
- disallow options nested options
- NULL out state variable in parser
- flip backwards comparison
- fix memory leak in lexer
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/grammar_sandbox.c')
| -rw-r--r-- | lib/grammar_sandbox.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index 39d4d6b7cd..cf9ce2bb58 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -63,7 +63,7 @@ DEFUN (grammar_test, // initialize a pretend cmd_element struct cmd_element *cmd = XCALLOC(MTYPE_CMD_TOKENS, sizeof(struct cmd_element)); - cmd->string = command; + cmd->string = XSTRDUP(MTYPE_TMP, command); cmd->doc = NULL; cmd->func = NULL; cmd->tokens = vector_init(VECTOR_MIN_SIZE); @@ -132,6 +132,9 @@ DEFUN (grammar_test_match, "command to match") { char *cmdstr = argv_concat(argv, argc, 0); + if (cmdstr[0] == '#') + return CMD_SUCCESS; + vector command = cmd_make_strvec (cmdstr); struct list *argvv = NULL; @@ -145,7 +148,7 @@ DEFUN (grammar_test_match, struct listnode *ln; struct graph_node *gn; for (ALL_LIST_ELEMENTS_RO(argvv,ln,gn)) - if (gn->type != END_GN) + if (gn->type == END_GN) zlog_info ("func: %p", gn->element->func); else zlog_info ("%s -- %s", gn->text, gn->arg); |
