[Bug #19242] Prohibit circular causes to be loaded

This commit is contained in:
Nobuyoshi Nakada 2022-12-19 14:10:58 +09:00
parent 18ba89093a
commit 2e7e153a2a
Notes: git 2022-12-20 05:13:10 +00:00
4 changed files with 31 additions and 0 deletions

4
eval.c
View file

@ -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) {
#if 0 /* maybe critical for some cases */
rb_exc_check_circular_cause(*cause);
#else
VALUE c = *cause;
while (!NIL_P(c = rb_attr_get(c, id_cause))) {
if (c == mesg) {
rb_raise(rb_eArgError, "circular causes");
}
}
#endif
}
return mesg;
}