From c3f24f0653a139737598c9d90d0d4dc61898691f Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Sat, 1 Oct 2016 01:03:24 +0000 Subject: [PATCH] lib: Fix '?'-completion dereferences in vtysh Signed-off-by: Quentin Young --- vtysh/vtysh.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 53f63256be..de973cf4ce 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -823,32 +823,25 @@ vtysh_rl_describe (void) for (i = 0; i < vector_active (describe); i++) if ((token = vector_slot (describe, i)) != NULL) { - int len; - - if (token->arg[0] == '\0') - continue; + if (token->text[0] == '\0') + continue; - len = strlen (token->arg); - if (token->arg[0] == '.') - len--; + int len = strlen (token->text); - if (width < len) - width = len; + if (width < len) + width = len; } for (i = 0; i < vector_active (describe); i++) if ((token = vector_slot (describe, i)) != NULL) { - if (token->arg[0] == '\0') - continue; - if (! token->desc) fprintf (stdout," %-s\n", - token->arg[0] == '.' ? token->arg + 1 : token->arg); + token->text); else fprintf (stdout," %-*s %s\n", width, - token->arg[0] == '.' ? token->arg + 1 : token->arg, + token->text, token->desc); } -- 2.39.5