diff options
author | nagachika <nagachika@ruby-lang.org> | 2023-03-25 11:04:33 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2023-03-25 11:04:33 +0900 |
commit | 810ae06c06312908fc1a7284773d8a9101ee145b (patch) | |
tree | 5b9dd70da37a85caac30c80e71b5dbc4efd08665 /eval_error.c | |
parent | 8c99882dad0b6fedbd656889829a3780366bd8b6 (diff) |
merge revision(s) 2e7e153a2af1456515d43b6381e38534b069b1c2: [Backport #19242]
[Bug #19242] Prohibit circular causes to be loaded
---
error.c | 4 ++++
eval.c | 4 ++++
eval_error.c | 11 +++++++++++
test/ruby/test_exception.rb | 12 ++++++++++++
4 files changed, 31 insertions(+)
Diffstat (limited to 'eval_error.c')
-rw-r--r-- | eval_error.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/eval_error.c b/eval_error.c index 9b453eede0..1baa4484a0 100644 --- a/eval_error.c +++ b/eval_error.c @@ -311,6 +311,17 @@ show_cause(VALUE errinfo, VALUE str, VALUE highlight, VALUE reverse, long backtr } void +rb_exc_check_circular_cause(VALUE exc) +{ + VALUE cause = exc, shown_causes = 0; + do { + if (shown_cause_p(cause, &shown_causes)) { + rb_raise(rb_eArgError, "circular causes"); + } + } while (!NIL_P(cause = rb_attr_get(cause, id_cause))); +} + +void rb_error_write(VALUE errinfo, VALUE emesg, VALUE errat, VALUE str, VALUE highlight, VALUE reverse) { volatile VALUE eclass; |