[前][次][番号順一覧][スレッド一覧]

ruby-changes:34973

From: nagachika <ko1@a...>
Date: Mon, 4 Aug 2014 01:31:57 +0900 (JST)
Subject: [ruby-changes:34973] nagachika:r47055 (ruby_2_1): merge revision(s) r46570: [Backport #9983]

nagachika	2014-08-04 01:31:45 +0900 (Mon, 04 Aug 2014)

  New Revision: 47055

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47055

  Log:
    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]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/hash.c
    branches/ruby_2_1/test/ruby/test_env.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 47054)
+++ ruby_2_1/ChangeLog	(revision 47055)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Mon Aug  4 01:29:57 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* hash.c (env_shift): fix memory leak on Windows, free environment
+	  strings block always.  [ruby-dev:48332] [Bug #9983]
+
 Mon Aug  4 01:26:46 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* hash.c (env_select): fix memory leak and crash on Windows, make
Index: ruby_2_1/hash.c
===================================================================
--- ruby_2_1/hash.c	(revision 47054)
+++ ruby_2_1/hash.c	(revision 47055)
@@ -3557,6 +3557,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_1/hash.c#L3557
 env_shift(void)
 {
     char **env;
+    VALUE result = Qnil;
 
     env = GET_ENVIRON(environ);
     if (*env) {
@@ -3565,11 +3566,11 @@ env_shift(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/hash.c#L3566
 	    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;
 }
 
 /*
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 47054)
+++ ruby_2_1/version.h	(revision 47055)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.2"
 #define RUBY_RELEASE_DATE "2014-08-04"
-#define RUBY_PATCHLEVEL 193
+#define RUBY_PATCHLEVEL 194
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 8
Index: ruby_2_1/test/ruby/test_env.rb
===================================================================
--- ruby_2_1/test/ruby/test_env.rb	(revision 47054)
+++ ruby_2_1/test/ruby/test_env.rb	(revision 47055)
@@ -434,4 +434,13 @@ class TestEnv < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_env.rb#L434
       ENV.select {ENV.clear}
     end;
   end
+
+  def test_memory_leak_shift
+    bug9983 = '[ruby-dev:48332] [Bug #9983]'
+    assert_no_memory_leak([], <<-'end;', "5_000.times {ENV.shift; ENV[k] = v}", bug9983)
+      ENV.clear
+      k = 'FOO'
+      v = (ENV[k] = 'bar'*5000 rescue 'bar'*1500)
+    end;
+  end
 end

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r46570


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]