vtysh: protect null deref for cli completions

cmd_describe_command() returns NULL when there is no matched command, so
check the return value before trying to free it

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2017-11-02 11:50:13 -04:00
parent e919cf55bd
commit 9320658c0d
No known key found for this signature in database
GPG Key ID: DAF48E0F57E0834F

View File

@ -820,7 +820,8 @@ static int vtysh_rl_describe(void)
break;
case CMD_ERR_NO_MATCH:
cmd_free_strvec(vline);
vector_free(describe);
if (describe)
vector_free(describe);
fprintf(stdout, "%% There is no matched command.\n");
rl_on_new_line();
return 0;