summaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorlijinhui <lijh_7@chinatelecom.cn>2024-02-22 11:16:10 +0800
committerDamjan Marion <dmarion@0xa5.net>2024-04-01 17:57:58 +0000
commiteb2a4189f5962e6345cd10e7d7a3267451dc04bb (patch)
tree5a73f7a88cf1a2a114469cd4ec766be3e2301be4 /src/vlib
parent5e814768b8d21fe4812b63a38b88bb1175404ed8 (diff)
vlib: fix counter_index check
Ensure counter index is valid before using it to lookup the counter. Type: fix Change-Id: I423c7a6aa6b65f6367b18d8e99cf40f52e06b416 Signed-off-by: lijinhui <lijh_7@chinatelecom.cn>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/drop.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/vlib/drop.c b/src/vlib/drop.c
index 66eb98fb899..3fda1d9b3b6 100644
--- a/src/vlib/drop.c
+++ b/src/vlib/drop.c
@@ -93,10 +93,12 @@ format_error_trace (u8 * s, va_list * va)
u32 i;
error_node = vlib_get_node (vm, vlib_error_get_node (&vm->node_main, e[0]));
- i = counter_index (vm, vlib_error_get_code (&vm->node_main, e[0])) +
- error_node->error_heap_index;
+ i = counter_index (vm, vlib_error_get_code (&vm->node_main, e[0]));
if (i != CLIB_U32_MAX)
- s = format (s, "%v: %s", error_node->name, em->counters_heap[i].desc);
+ {
+ i += error_node->error_heap_index;
+ s = format (s, "%v: %s", error_node->name, em->counters_heap[i].desc);
+ }
return s;
}