summaryrefslogtreecommitdiff
path: root/eval_error.c
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2023-07-22 14:01:55 +0900
committernagachika <nagachika@ruby-lang.org>2023-07-22 14:01:55 +0900
commitb97a744a3778abe52fffb051e1460a0a6f7c4a6d (patch)
treeed3958e1170b8671737176040d3b2c41116a1e63 /eval_error.c
parent65d294ad019c8ac5bba12e2c9098360bacafc9e3 (diff)
merge revision(s) 9c94db7cfc584e982a6449b72e58a1cf25024177,fe4d906f5fbacbe6e9267af3bd3503339bad63a9: [Backport #19774]
Add tests for `return` in `BEGIN` and `END` blocks --- spec/ruby/language/return_spec.rb | 15 +++++++++++++++ test/ruby/test_syntax.rb | 1 + 2 files changed, 16 insertions(+) [Bug #19774] Fix segfault at `return` in `END` --- eval_error.c | 7 ++++++- test/ruby/test_syntax.rb | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-)
Diffstat (limited to 'eval_error.c')
-rw-r--r--eval_error.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/eval_error.c b/eval_error.c
index 948a205dd9..9806683000 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -455,7 +455,12 @@ exiting_split(VALUE errinfo, volatile int *exitcode, volatile int *sigstatus)
if (NIL_P(errinfo)) return 0;
- if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
+ if (THROW_DATA_P(errinfo)) {
+ int throw_state = ((const struct vm_throw_data *)errinfo)->throw_state;
+ ex = throw_state & VM_THROW_STATE_MASK;
+ result |= EXITING_WITH_STATUS;
+ }
+ else if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
ex = sysexit_status(errinfo);
result |= EXITING_WITH_STATUS;
}