From 6564992f2464e561d11f82f65731bc0c44ea9e2a Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 24 Aug 2020 13:19:44 +0200 Subject: main.c: do not dump operands of extended opcodes Extendend opcodes might have non-opcode operands which we cannot safely dereference. Signed-off-by: Jo-Philipp Wich --- main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index d1bb463..99bd3c8 100644 --- a/main.c +++ b/main.c @@ -107,10 +107,12 @@ static void dump(struct ut_opcode *op, int level) { for (prev = NULL, cur = op; cur; prev = cur, cur = cur->sibling) { dump_node(cur); - for (i = 0; i < sizeof(cur->operand) / sizeof(cur->operand[0]); i++) { - if (cur->operand[i]) { - dump(cur->operand[i], level + 1); - printf("n%p -> n%p [label=\"op%d\"];\n", cur, cur->operand[i], i + 1); + if (cur->type < __T_MAX) { + for (i = 0; i < sizeof(cur->operand) / sizeof(cur->operand[0]); i++) { + if (cur->operand[i]) { + dump(cur->operand[i], level + 1); + printf("n%p -> n%p [label=\"op%d\"];\n", cur, cur->operand[i], i + 1); + } } } -- cgit v1.2.3