Project

General

Profile

Bug #14566 ยป fix-bug-14566.patch

ujihisa (Tatsuhiro Ujihisa), 04/10/2018 12:55 PM

View differences:

eval_error.c
220 220
    }
221 221
}
222 222

  
223
VALUE rb_call_message(VALUE recv)
224
{
225
  return rb_funcall(recv, rb_intern("message"), 0);
226
}
227

  
223 228
void
224 229
rb_error_write(VALUE errinfo, VALUE errat, VALUE str, VALUE highlight, VALUE reverse)
225 230
{
......
232 237
	errat = Qnil;
233 238
    }
234 239
    if ((eclass = CLASS_OF(errinfo)) != Qundef) {
235
	VALUE e = rb_check_funcall(errinfo, rb_intern("message"), 0, 0);
236
	if (e != Qundef) {
237
	    if (!RB_TYPE_P(e, T_STRING)) e = rb_check_string_type(e);
238
	    emesg = e;
239
	}
240
      int state = 0;
241
      VALUE e = rb_protect(rb_call_message, errinfo, &state);
242
      if (state) rb_warning("Exception caught automatically in \"message\" method");
243
      if (!RB_TYPE_P(e, T_STRING)) e = rb_check_string_type(e);
244
      emesg = e;
240 245
    }
241 246
    if (NIL_P(reverse) || NIL_P(highlight)) {
242 247
	VALUE tty = (VALUE)rb_stderr_tty_p();
test/ruby/test_exception.rb
1309 1309
      assert_operator(message, :end_with?, top)
1310 1310
    end
1311 1311
  end
1312

  
1313
  # def test_message_with_exception_wont_cause_infinite_loop
1314
  #   bug14566 = '[Bug #14566]'
1315
  #   assert_nothing_raised(Exception, bug14566) do
1316
  #     eclass = Class.new(StandardError) do
1317
  #       def message
1318
  #         raise
1319
  #       end
1320
  #     end
1321

  
1322
  #     begin
1323
  #       raise eclass
1324
  #     rescue => e
1325
  #       e.message
1326
  #     end
1327
  #   end
1328
  # end
1312 1329
end