Skip to content

Commit be5f8cf

Browse files
committed
Fix rb_rescue2() to stop when seeing the (VALUE)0 argument
* The previous version of the spec would pass unintentionally due to (VALUE)0 == Qfalse and the rescue nodes raising TypeError (class or module required for rescue clause).
1 parent 9e9de91 commit be5f8cf

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Bug fixes:
4040
* Fixed `SystemStackError` sometimes replaced by an internal Java `NoClassDefFoundError` on JVM (#1743).
4141
* Fixed constant/identifier detection in lexer for non-ASCII encodings (#2079, #2102, @ivoanjo).
4242
* Fixed parsing of `--jvm` as an application argument (#2108).
43+
* Fix `rb_rescue2` to ignore the end marker `(VALUE)0` (#2127, #2130).
4344

4445
Compatibility:
4546

src/main/c/cext/exception.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ VALUE rb_rescue2(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*r_proc)(ANYARGS)
8585
// arguments using the polyglot api.
8686
for (;n < total; n++) {
8787
VALUE arg = polyglot_get_arg(n);
88+
if (arg == (VALUE)0) {
89+
break;
90+
}
91+
8892
rb_ary_push(rescued, arg);
8993
}
9094
return cext_rb_rescue2(b_proc, data1, r_proc, data2, rb_tr_unwrap(rescued));

0 commit comments

Comments
 (0)