diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-10 12:34:26 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-10 12:34:26 +0000 |
commit | 3875df97f1ff78c376543a2c3cb32ab6aada69bc (patch) | |
tree | 2faa35c2634561a04d05bc25363c31044ee98d4b /vm.c | |
parent | f5299e93a7914e8ba588031a0603014c73a6c3fa (diff) |
proc.c, vm.c: fix possible memory leak
* proc.c (proc_binding): fix possible memory leak of rb_env_t when
TypedData_Wrap_Struct failed.
* vm.c (vm_make_env_each): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -507,6 +507,7 @@ vm_make_env_each(const rb_thread_t *const th, rb_control_frame_t *const cfp, local_size = cfp->iseq->local_size; } + envval = TypedData_Wrap_Struct(rb_cEnv, &env_data_type, 0); /* allocate env */ env = xmalloc(sizeof(rb_env_t) + ((local_size + 1) * sizeof(VALUE))); env->env_size = local_size + 1 + 1; @@ -525,7 +526,7 @@ vm_make_env_each(const rb_thread_t *const th, rb_control_frame_t *const cfp, #endif /* be careful not to trigger GC after this */ - envval = TypedData_Wrap_Struct(rb_cEnv, &env_data_type, env); + RTYPEDDATA_DATA(envval) = env; /* * must happen after TypedData_Wrap_Struct to ensure penvval is markable |