summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-08-24 13:19:44 +0200
committerJo-Philipp Wich <jo@mein.io>2020-08-25 20:38:15 +0200
commit6564992f2464e561d11f82f65731bc0c44ea9e2a (patch)
treec420456e1c896bc814b1c1a63a853202c48f9639
parentba38eff1c22cab91fc1a47a24dc7c03a458640aa (diff)
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 <jo@mein.io>
-rw-r--r--main.c10
1 files 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);
+ }
}
}