From ec588537889c84a4ec649a6f1aa9d7f1bfea7b4d Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 7 Nov 2023 11:33:35 +0300 Subject: [PATCH] Validate opcode --- ir_check.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ir_check.c b/ir_check.c index 1993ee1..1dbe4a7 100644 --- a/ir_check.c +++ b/ir_check.c @@ -95,6 +95,11 @@ bool ir_check(const ir_ctx *ctx) bool ok = 1; for (i = IR_UNUSED + 1, insn = ctx->ir_base + i; i < ctx->insns_count;) { + if (insn->op >= IR_LAST_OP) { + fprintf(stderr, "ir_base[%d].op invalid opcode (%d)\n", i, insn->op); + ok = 0; + break; + } flags = ir_op_flags[insn->op]; n = ir_input_edges_count(ctx, insn); for (j = 1, p = insn->ops + 1; j <= n; j++, p++) {