1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c (ruby_cleanup): fixed access to out of bound, and inversed

the order of errinfos.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-04-20 03:20:44 +00:00
parent 52ecaf65b0
commit cc1757bce8
2 changed files with 21 additions and 12 deletions

View file

@ -1,3 +1,8 @@
Fri Apr 20 12:21:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (ruby_cleanup): fixed access to out of bound, and inversed
the order of errinfos.
Fri Apr 20 10:33:23 2007 Koichi Sasada <ko1@atdot.net> Fri Apr 20 10:33:23 2007 Koichi Sasada <ko1@atdot.net>
* eval_intern.h: add prototypes of rb_sourceline() and * eval_intern.h: add prototypes of rb_sourceline() and

28
eval.c
View file

@ -153,38 +153,42 @@ ruby_finalize(void)
int int
ruby_cleanup(int ex) ruby_cleanup(int ex)
{ {
int state, i; int state, nerr;
volatile VALUE errs[2] = {GET_THREAD()->errinfo, 0}; VALUE err;
rb_vm_t *vm = GET_THREAD()->vm; rb_thread_t *th = GET_THREAD();
volatile VALUE errs[2];
rb_vm_t *vm = th->vm;
GET_THREAD()->safe_level = 0; errs[0] = th->errinfo;
th->safe_level = 0;
Init_stack((void *)&state); Init_stack((void *)&state);
ruby_finalize_0();
errs[1] = th->errinfo;
PUSH_THREAD_TAG(); PUSH_THREAD_TAG();
if ((state = EXEC_TAG()) == 0) { if ((state = EXEC_TAG()) == 0) {
ruby_finalize_0(); rb_thread_terminate_all();
} }
else if (ex == 0) { else if (ex == 0) {
ex = state; ex = state;
} }
errs[1] = GET_THREAD()->errinfo; th->errinfo = errs[0];
rb_thread_terminate_all();
GET_THREAD()->errinfo = errs[0];
ex = error_handle(ex); ex = error_handle(ex);
ruby_finalize_1(); ruby_finalize_1();
POP_THREAD_TAG(); POP_THREAD_TAG();
rb_thread_stop_timer_thread(); rb_thread_stop_timer_thread();
for (i = 2; i > 0; --i) { for (nerr = sizeof(errs) / sizeof(errs[0]); nerr;) {
VALUE err = errs[i]; if (!RTEST(err = errs[--nerr])) continue;
/* th->errinfo contains a NODE while break'ing */ /* th->errinfo contains a NODE while break'ing */
if (!RTEST(err) || (TYPE(err) == T_NODE)) continue; if (TYPE(err) == T_NODE) continue;
if (rb_obj_is_kind_of(err, rb_eSystemExit)) { if (rb_obj_is_kind_of(err, rb_eSystemExit)) {
return sysexit_status(err); return sysexit_status(err);
} }
else if (rb_obj_is_kind_of(err, rb_eSignal)) { else if (rb_obj_is_kind_of(err, rb_eSignal)) {
ruby_default_signal(NUM2INT(rb_iv_get(err, "signo"))); VALUE sig = rb_iv_get(err, "signo");
ruby_default_signal(NUM2INT(sig));
} }
} }