mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Protect from exceptions raised outside of mrb_vm_run().
It can happen if signals are used (e.g. from `mruby-alarm` gem).
This commit is contained in:
@@ -56,6 +56,7 @@
|
|||||||
#include <mruby/dump.h>
|
#include <mruby/dump.h>
|
||||||
#include <mruby/string.h>
|
#include <mruby/string.h>
|
||||||
#include <mruby/variable.h>
|
#include <mruby/variable.h>
|
||||||
|
#include <mruby/throw.h>
|
||||||
|
|
||||||
#ifdef ENABLE_READLINE
|
#ifdef ENABLE_READLINE
|
||||||
|
|
||||||
@@ -491,7 +492,10 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
char *utf8;
|
char *utf8;
|
||||||
|
struct mrb_jmpbuf c_jmp;
|
||||||
|
|
||||||
|
MRB_TRY(&c_jmp);
|
||||||
|
mrb->jmp = &c_jmp;
|
||||||
if (args.rfp) {
|
if (args.rfp) {
|
||||||
if (fgets(last_code_line, sizeof(last_code_line)-1, args.rfp) != NULL)
|
if (fgets(last_code_line, sizeof(last_code_line)-1, args.rfp) != NULL)
|
||||||
goto done;
|
goto done;
|
||||||
@@ -555,8 +559,7 @@ main(int argc, char **argv)
|
|||||||
MIRB_LINE_FREE(line);
|
MIRB_LINE_FREE(line);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
if (code_block_open) {
|
if (code_block_open) {
|
||||||
if (strlen(ruby_code)+strlen(last_code_line) > sizeof(ruby_code)-1) {
|
if (strlen(ruby_code)+strlen(last_code_line) > sizeof(ruby_code)-1) {
|
||||||
fputs("concatenated input string too long\n", stderr);
|
fputs("concatenated input string too long\n", stderr);
|
||||||
@@ -648,6 +651,11 @@ done:
|
|||||||
}
|
}
|
||||||
mrb_parser_free(parser);
|
mrb_parser_free(parser);
|
||||||
cxt->lineno++;
|
cxt->lineno++;
|
||||||
|
MRB_CATCH(&c_jmp) {
|
||||||
|
p(mrb, mrb_obj_value(mrb->exc), 0);
|
||||||
|
mrb->exc = 0;
|
||||||
|
}
|
||||||
|
MRB_END_EXC(&c_jmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_READLINE
|
#ifdef ENABLE_READLINE
|
||||||
|
|||||||
Reference in New Issue
Block a user