Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
86d10235
Commit
86d10235
authored
Nov 20, 2018
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restrict total recursion number of `ecall()`; fix #3789
parent
afd46ecc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
include/mruby.h
include/mruby.h
+2
-1
src/vm.c
src/vm.c
+4
-2
No files found.
include/mruby.h
View file @
86d10235
...
...
@@ -267,7 +267,8 @@ typedef struct mrb_state {
#else
mrb_atexit_func
*
atexit_stack
;
#endif
mrb_int
atexit_stack_len
;
uint16_t
atexit_stack_len
;
uint16_t
ecall_nest
;
/* prevent infinite recursive ecall() */
}
mrb_state
;
/**
...
...
src/vm.c
View file @
86d10235
...
...
@@ -55,7 +55,7 @@ void abort(void);
/* Maximum depth of ecall() recursion. */
#ifndef MRB_ECALL_DEPTH_MAX
#define MRB_ECALL_DEPTH_MAX
3
2
#define MRB_ECALL_DEPTH_MAX
51
2
#endif
/* Maximum stack depth. Should be set lower on memory constrained systems.
...
...
@@ -337,7 +337,8 @@ ecall(mrb_state *mrb)
int
nregs
;
if
(
i
<
0
)
return
;
if
(
ci
-
c
->
cibase
>
MRB_ECALL_DEPTH_MAX
)
{
/* restrict total call depth of ecall() */
if
(
++
mrb
->
ecall_nest
>
MRB_ECALL_DEPTH_MAX
)
{
mrb_exc_raise
(
mrb
,
mrb_obj_value
(
mrb
->
stack_err
));
}
p
=
c
->
ensure
[
i
];
...
...
@@ -372,6 +373,7 @@ ecall(mrb_state *mrb)
c
->
ci
=
c
->
cibase
+
cioff
;
if
(
!
mrb
->
exc
)
mrb
->
exc
=
exc
;
mrb_gc_arena_restore
(
mrb
,
ai
);
mrb
->
ecall_nest
--
;
}
#ifndef MRB_FUNCALL_ARGC_MAX
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment