Skip to content

Commit 12f57d1

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). (cherry picked from commit be5f8cf)
1 parent 76afd2d commit 12f57d1

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
@@ -19,6 +19,7 @@ Bug fixes:
1919
* Fixed `SystemStackError` sometimes replaced by an internal Java `NoClassDefFoundError` on JVM (#1743).
2020
* Fixed constant/identifier detection in lexer for non-ASCII encodings (#2079, #2102, @ivoanjo).
2121
* Fixed parsing of `--jvm` as an application argument (#2108).
22+
* Fix `rb_rescue2` to ignore the end marker `(VALUE)0` (#2127, #2130).
2223

2324
Compatibility:
2425

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)