diff mbox

[dpdk-dev] librte_cmdline: fix parsing initialisation

Message ID 1497348447-1167-1-git-send-email-bernard.iremonger@intel.com (mailing list archive)
State Superseded, archived
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Bernard Iremonger June 13, 2017, 10:07 a.m. UTC
From: "Bernard.Iremonger" <Bernard.iremonger@intel.com>

The dyn_tokens array is initialised at the beginning of
the cmdline_parse function. However when the inst_num
variable is incremented later in the function the
dyn_tokens array is not reinitialised so the tokens
from the previous command are used.

The solution is to initialise the dyn_tokens array in
the while(inst) loop.

Fixes: 4fffc05a2b2c ("cmdline: support dynamic tokens")

CC: stable@dpdk.org
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_cmdline/cmdline_parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c
index b814880..9ee28b8 100644
--- a/lib/librte_cmdline/cmdline_parse.c
+++ b/lib/librte_cmdline/cmdline_parse.c
@@ -276,7 +276,6 @@ 
 		return CMDLINE_PARSE_BAD_ARGS;
 
 	ctx = cl->ctx;
-	memset(&dyn_tokens, 0, sizeof(dyn_tokens));
 
 	/*
 	 * - look if the buffer contains at least one line
@@ -319,6 +318,7 @@ 
 	inst = ctx[inst_num];
 	while (inst) {
 		debug_printf("INST %d\n", inst_num);
+		memset(&dyn_tokens, 0, sizeof(dyn_tokens));
 
 		/* fully parsed */
 		tok = match_inst(inst, buf, 0, tmp_result.buf,