aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-27 03:45:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-27 03:45:55 +0000
commit02e1dbba9a3d633416bd2c1c551360b0450d3ff9 (patch)
tree3de46c053f2149c4b6ee420a7105816787895ae4
parent638740bd9af6d94dde88dcec6274a0f738540b79 (diff)
downloadruby-02e1dbba9a3d633416bd2c1c551360b0450d3ff9.tar.gz
vm_insnhelper.c: break in once
* vm_insnhelper.c (vm_throw_start): size of catch table has been included in iseq_catch_table struct, which could be NULL, since 2.2. e.g., proc-closure in `once'. [ruby-core:81775] [Bug #13680] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_exception.rb11
-rw-r--r--vm_insnhelper.c12
2 files changed, 17 insertions, 6 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index 6955118de7..ecbf042e49 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -1080,4 +1080,15 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
}
end;
end
+
+ def test_break_in_once
+ assert_separately([], "#{<<-"begin;"}\n#{<<~'end;'}")
+ begin;
+ obj = Object.new
+ def obj.try
+ /#{break}/o
+ end
+ assert_raise(LocalJumpError, /proc-closure/) {obj.try}
+ end;
+ end
end
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 35684e6ed1..eea16d730e 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1083,13 +1083,13 @@ vm_throw_start(rb_thread_t *const th, rb_control_frame_t *const reg_cfp, enum ru
while (escape_cfp < eocfp) {
if (escape_cfp->ep == ep) {
- const VALUE epc = escape_cfp->pc - escape_cfp->iseq->body->iseq_encoded;
- const rb_iseq_t * const iseq = escape_cfp->iseq;
- const struct iseq_catch_table * const ct = iseq->body->catch_table;
- const int ct_size = ct->size;
- int i;
+ const rb_iseq_t *const iseq = escape_cfp->iseq;
+ const VALUE epc = escape_cfp->pc - iseq->body->iseq_encoded;
+ const struct iseq_catch_table *const ct = iseq->body->catch_table;
+ unsigned int i;
- for (i=0; i<ct_size; i++) {
+ if (!ct) break;
+ for (i=0; i < ct->size; i++) {
const struct iseq_catch_table_entry * const entry = &ct->entries[i];
if (entry->type == CATCH_TYPE_BREAK &&