summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-26 20:33:34 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-26 20:33:34 (GMT)
commit68bc5ba1b6695f80623441cb60436801add42757 (patch)
tree3d4590136e772f6888243551124fc2168a0d9f9b /hash.c
parentcfa7b2283b9b53ff8689d510d486f3488d9254d1 (diff)
hash.c: fix memory leak
* hash.c (env_shift): fix memory leak on Windows, free environment strings block always. [ruby-dev:48332] [Bug #9983] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index bcf6b5e..348e5fb 100644
--- a/hash.c
+++ b/hash.c
@@ -3554,6 +3554,7 @@ static VALUE
env_shift(void)
{
char **env;
+ VALUE result = Qnil;
env = GET_ENVIRON(environ);
if (*env) {
@@ -3562,11 +3563,11 @@ env_shift(void)
VALUE key = env_str_new(*env, s-*env);
VALUE val = env_str_new2(getenv(RSTRING_PTR(key)));
env_delete(Qnil, key);
- return rb_assoc_new(key, val);
+ result = rb_assoc_new(key, val);
}
}
FREE_ENVIRON(environ);
- return Qnil;
+ return result;
}
/*