vlib: fix coverity warning / real bug 29/24229/1
authorDave Barach <dave@barachs.net>
Tue, 7 Jan 2020 17:29:10 +0000 (12:29 -0500)
committerDave Barach <dave@barachs.net>
Tue, 7 Jan 2020 17:29:39 +0000 (12:29 -0500)
The path must be next-to-impossible to hit, because the code has been
wrong for at least 5 years.

Type: fix

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I23b8c4e1631827e7931f353c561c1e19c596c598

src/vlib/cli.c

index 467d1f7..bb6c574 100644 (file)
@@ -1217,7 +1217,7 @@ add_sub_command (vlib_cli_main_t * cm, uword parent_index, uword child_index)
                    vec_len (p->sub_rules));
       vec_add2 (p->sub_rules, sr, 1);
       sr->name = sub_name;
-      sr->rule_index = q[0];
+      sr->rule_index = sr - p->sub_rules;
       sr->command_index = child_index;
       return;
     }