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>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-01-04 14:09:57 +09:00
parent 2e4a8e8edd
commit 6b482ee3f8
+1 -1
View File
@@ -3123,7 +3123,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_STRCAT, B) {
mrb_assert(mrb_string_p(regs[a]));
mrb_ensure_string_type(mrb, regs[a]);
mrb_str_concat(mrb, regs[a], regs[a+1]);
ci = mrb->c->ci;
NEXT;