mruby-compiler: fix sp tracking in pattern match failure path

After pattern matching code generation, the sp (stack pointer) must
be restored to match the success path value. The failure path (after
RAISEIF) left sp in a different state, causing incorrect register
allocation in subsequent code like string interpolation.

This caused OP_STRCAT to use the wrong register, leading to
null-dereference when trying to modify a non-string value as a string.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-01-04 09:12:35 +09:00
parent 099d2c4771
commit 2e4a8e8edd
+3
View File
@@ -6667,6 +6667,9 @@ codegen(codegen_scope *s, node *tree, int val)
/* End of pattern matching */
dispatch(s, match_pos);
/* Restore sp to match success path value */
s->sp = saved_sp - 1;
if (val) push();
}
else {
/* Pattern always matches - pop value and push result if needed */