diff options
author | Nobuyoshi Nakada <[email protected]> | 2022-12-19 14:10:58 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2022-12-20 14:12:38 +0900 |
commit | 2e7e153a2af1456515d43b6381e38534b069b1c2 () | |
tree | a7c1730d6b86170e9e80f2e9705ea824ed517829 | |
parent | 18ba89093a0b214cd89f1567c037c239f094496d (diff) |
[Bug #19242] Prohibit circular causes to be loaded
Notes: Merged: https://.com/ruby/ruby/pull/6960
-rw-r--r-- | error.c | 4 | ||||
-rw-r--r-- | eval.c | 4 | ||||
-rw-r--r-- | eval_error.c | 11 | ||||
-rw-r--r-- | test/ruby/test_exception.rb | 12 |
4 files changed, 31 insertions, 0 deletions
@@ -2959,6 +2959,8 @@ ivar_copy_i(st_data_t key, st_data_t val, st_data_t exc) return ST_CONTINUE; } static VALUE exception_loader(VALUE exc, VALUE obj) { @@ -2973,6 +2975,8 @@ exception_loader(VALUE exc, VALUE obj) rb_ivar_foreach(obj, ivar_copy_i, exc); if (rb_attr_get(exc, id_bt) == rb_attr_get(exc, id_bt_locations)) { rb_ivar_set(exc, id_bt_locations, Qnil); } @@ -537,12 +537,16 @@ exc_setup_message(const rb_execution_context_t *ec, VALUE mesg, VALUE *cause) } if (!nocircular && !NIL_P(*cause) && !UNDEF_P(*cause) && *cause != mesg) { VALUE c = *cause; while (!NIL_P(c = rb_attr_get(c, id_cause))) { if (c == mesg) { rb_raise(rb_eArgError, "circular causes"); } } } return mesg; } @@ -291,6 +291,17 @@ show_cause(VALUE errinfo, VALUE str, VALUE opt, VALUE highlight, VALUE reverse, } void rb_error_write(VALUE errinfo, VALUE emesg, VALUE errat, VALUE str, VALUE opt, VALUE highlight, VALUE reverse) { volatile VALUE eclass; @@ -1412,6 +1412,18 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| end; end def test_super_in_method_missing assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; |