summaryrefslogtreecommitdiffhomepage
path: root/src/gc.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-04-10 21:12:41 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-04-10 21:12:41 +0900
commit0048dd118a0d57ff87265593819f9e93e05fafed (patch)
tree5115618de51eb7dba2713ce94e58dbf0b03db2df /src/gc.c
parenta55b237d89e1397da8dc879b24c1a34e80ad4e91 (diff)
downloadmruby-0048dd118a0d57ff87265593819f9e93e05fafed.tar.gz
mruby-0048dd118a0d57ff87265593819f9e93e05fafed.zip
Protect arguments from GC; fix #3597
GC may be called with OP_ENTER (especially when GC_STRESS is set).
Diffstat (limited to 'src/gc.c')
-rw-r--r--src/gc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gc.c b/src/gc.c
index 19bc1ad4b..db70587d5 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -545,10 +545,16 @@ mark_context_stack(mrb_state *mrb, struct mrb_context *c)
size_t i;
size_t e;
mrb_value nil;
+ int nregs;
if (c->stack == NULL) return;
e = c->stack - c->stbase;
- if (c->ci) e += c->ci->nregs;
+ if (c->ci) {
+ nregs = c->ci->argc + 2;
+ if (c->ci->nregs > nregs)
+ nregs = c->ci->nregs;
+ e += nregs;
+ }
if (c->stbase + e > c->stend) e = c->stend - c->stbase;
for (i=0; i<e; i++) {
mrb_value v = c->stbase[i];