Skip to content

Commit 6b482ee

Browse files
matzclaude
andcommitted
vm.c: add runtime type check for OP_STRCAT
Replace mrb_assert with mrb_ensure_string_type to catch codegen bugs even in release builds. This prevents null-dereference crashes when OP_STRCAT receives a non-string first operand due to compiler bugs. Consistent with OP_HASH which uses mrb_ensure_hash_type for similar type safety. Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2e4a8e8 commit 6b482ee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/vm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3123,7 +3123,7 @@ mrb_vm_exec(mrb_state *mrb, const struct RProc *begin_proc, const mrb_code *iseq
31233123
}
31243124

31253125
CASE(OP_STRCAT, B) {
3126-
mrb_assert(mrb_string_p(regs[a]));
3126+
mrb_ensure_string_type(mrb, regs[a]);
31273127
mrb_str_concat(mrb, regs[a], regs[a+1]);
31283128
ci = mrb->c->ci;
31293129
NEXT;

0 commit comments

Comments
 (0)