From 856f4d49f15844d3da579e4c5e19dc1c3545ed28 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 3 Aug 2014 16:31:45 +0000 Subject: 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 --- hash.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'hash.c') 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; } /* -- cgit v1.2.3