Commit 9f0950d
codegen.c: fix stack tracking in pattern match branching code
When generating code for pattern matching with potential failures, the
success and failure paths both need to pop the matched value. At
runtime, only one path executes. But during codegen, both pop() calls
affected the compile-time stack pointer (cursp), corrupting register
allocation and causing heap-buffer-overflow when accessing symbol
tables with wrong indices.
Fix by saving/restoring the stack pointer around the branch point, so
each path correctly tracks the stack state independently.
Co-authored-by: Claude <noreply@anthropic.com>1 parent da2d652 commit 9f0950d
1 file changed
+7
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6603 | 6603 | | |
6604 | 6604 | | |
6605 | 6605 | | |
6606 | | - | |
6607 | | - | |
6608 | 6606 | | |
6609 | 6607 | | |
6610 | 6608 | | |
6611 | 6609 | | |
| 6610 | + | |
6612 | 6611 | | |
| 6612 | + | |
| 6613 | + | |
6613 | 6614 | | |
6614 | 6615 | | |
6615 | 6616 | | |
| |||
6636 | 6637 | | |
6637 | 6638 | | |
6638 | 6639 | | |
6639 | | - | |
| 6640 | + | |
| 6641 | + | |
6640 | 6642 | | |
6641 | 6643 | | |
6642 | 6644 | | |
| |||
6667 | 6669 | | |
6668 | 6670 | | |
6669 | 6671 | | |
6670 | | - | |
| 6672 | + | |
| 6673 | + | |
6671 | 6674 | | |
6672 | 6675 | | |
6673 | 6676 | | |
| |||
0 commit comments