mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix OP_DEBUG operand type and add NULL check for debug_op_hook
1. Change CASE(OP_DEBUG, Z) to CASE(OP_DEBUG, BBB) to match the definition in include/mruby/ops.h. The previous code declared Z (no operands) but then manually called FETCH_BBB(), which caused incorrect behavior with extended opcodes (OP_EXT1/2/3). 2. Add NULL check before calling debug_op_hook, consistent with how code_fetch_hook is handled. This prevents crashes when MRB_USE_DEBUG_HOOK is enabled but no hook function is set. Fixes: #5686
This commit is contained in:
@@ -3319,12 +3319,9 @@ RETRY_TRY_BLOCK:
|
||||
NEXT;
|
||||
}
|
||||
|
||||
CASE(OP_DEBUG, Z) {
|
||||
const mrb_code *pc = ci->pc;
|
||||
FETCH_BBB();
|
||||
ci->pc = pc;
|
||||
CASE(OP_DEBUG, BBB) {
|
||||
#ifdef MRB_USE_DEBUG_HOOK
|
||||
mrb->debug_op_hook(mrb, irep, ci->pc, regs);
|
||||
if (mrb->debug_op_hook) mrb->debug_op_hook(mrb, irep, ci->pc, regs);
|
||||
#else
|
||||
#ifndef MRB_NO_STDIO
|
||||
printf("OP_DEBUG %d %d %d\n", a, b, c);
|
||||
|
||||
Reference in New Issue
Block a user