summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-03 16:31:45 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-03 16:31:45 +0000
commit856f4d49f15844d3da579e4c5e19dc1c3545ed28 (patch)
tree820775a52491ac64791b8443ddbabe6ca3caddca /hash.c
parent85c48fdc312a923c1bfe0ed88fa302d6417d9402 (diff)
merge revision(s) r46570: [Backport #9983]
* 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/branches/ruby_2_1@47055 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 aae90f0fec..85be2decb7 100644
--- a/hash.c
+++ b/hash.c
@@ -3557,6 +3557,7 @@ static VALUE
env_shift(void)
{
char **env;
+ VALUE result = Qnil;
env = GET_ENVIRON(environ);
if (*env) {
@@ -3565,11 +3566,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;
}
/*