Skip to content
Permalink
Browse files
Fixed a possible memory leak.
  • Loading branch information
matz committed Apr 21, 2017
1 parent 15fba69 commit 5d67d9b10da2cae489d34f8b31914f081d80889b
Showing 1 changed file with 2 additions and 1 deletion.
@@ -257,15 +257,16 @@ MRB_API void
mrb_env_unshare(mrb_state *mrb, struct REnv *e)
{
size_t len = (size_t)MRB_ENV_STACK_LEN(e);
mrb_value *p = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*len);
ptrdiff_t cioff = e->cioff;
mrb_value *p;

if (!MRB_ENV_STACK_SHARED_P(e)) return;
MRB_ENV_UNSHARE_STACK(e);
if (!e->c) {
/* save block argument position (negated) */
e->cioff = -mrb->c->cibase[cioff].argc-1;
}
p = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*len);
if (len > 0) {
stack_copy(p, e->stack, len);
}

0 comments on commit 5d67d9b

Please sign in to comment.