diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-13 02:19:48 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-13 02:19:48 +0000 |
commit | f741fd2d9d55afb535c3fd5635b2ee5252bedb68 (patch) | |
tree | f83840d19364ef8d0b25463783279380d298edbe /lib/irb.rb | |
parent | 087d1d27495b32b0af4acd4616354eab84b897d2 (diff) | |
download | ruby-f741fd2d9d55afb535c3fd5635b2ee5252bedb68.tar.gz |
* lib/irb.rb: Prevent irb from crashing when exception with
nil backtrace is raised.
[fix GH-434][ruby-core:58078][Bug #9063]
* test/irb/test_raise_no_backtrace_exception.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/irb.rb')
-rw-r--r-- | lib/irb.rb | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/irb.rb b/lib/irb.rb index 9bd37c8b0b..1bbb6eceb8 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -497,7 +497,7 @@ module IRB end if exc print exc.class, ": ", exc, "\n" - if exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ && + if exc.backtrace && exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ && !(SyntaxError === exc) irb_bug = true else @@ -507,16 +507,18 @@ module IRB messages = [] lasts = [] levels = 0 - for m in exc.backtrace - m = @context.workspace.filter_backtrace(m) unless irb_bug - if m - if messages.size < @context.back_trace_limit - messages.push "\tfrom "+m - else - lasts.push "\tfrom "+m - if lasts.size > @context.back_trace_limit - lasts.shift - levels += 1 + if exc.backtrace + for m in exc.backtrace + m = @context.workspace.filter_backtrace(m) unless irb_bug + if m + if messages.size < @context.back_trace_limit + messages.push "\tfrom "+m + else + lasts.push "\tfrom "+m + if lasts.size > @context.back_trace_limit + lasts.shift + levels += 1 + end end end end |