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

ruby-changes:31265

From: nagachika <ko1@a...>
Date: Fri, 18 Oct 2013 02:09:14 +0900 (JST)
Subject: [ruby-changes:31265] nagachika:r43344 (ruby_2_0_0): merge revision(s) 43328: [Backport #9033]

nagachika	2013-10-18 02:09:07 +0900 (Fri, 18 Oct 2013)

  New Revision: 43344

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

  Log:
    merge revision(s) 43328: [Backport #9033]
    
    * win32/file.c (rb_file_expand_path_internal): fix memory leaks at
      a non-absolute home exception.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/test/ruby/test_file_exhaustive.rb
    branches/ruby_2_0_0/version.h
    branches/ruby_2_0_0/win32/file.c
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 43343)
+++ ruby_2_0_0/ChangeLog	(revision 43344)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Fri Oct 18 02:05:45 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/file.c (rb_file_expand_path_internal): fix memory leaks at
+	  a non-absolute home exception.
+
 Thu Oct 10 01:14:37 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* compar.c (cmp_eq): fail if recursion.  [ruby-core:57736] [Bug #9003]
Index: ruby_2_0_0/win32/file.c
===================================================================
--- ruby_2_0_0/win32/file.c	(revision 43343)
+++ ruby_2_0_0/win32/file.c	(revision 43344)
@@ -405,6 +405,7 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/win32/file.c#L405
 
 	if (PathIsRelativeW(whome) && !(whome_len >= 2 && IS_DIR_UNC_P(whome))) {
 	    xfree(wpath);
+	    xfree(whome);
 	    rb_raise(rb_eArgError, "non-absolute home");
 	}
 
@@ -470,6 +471,7 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/win32/file.c#L471
 	    if (PathIsRelativeW(whome) && !(whome_len >= 2 && IS_DIR_UNC_P(whome))) {
 		xfree(wpath);
 		xfree(wdir);
+		xfree(whome);
 		rb_raise(rb_eArgError, "non-absolute home");
 	    }
 
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 43343)
+++ ruby_2_0_0/version.h	(revision 43344)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2013-10-11"
-#define RUBY_PATCHLEVEL 335
+#define RUBY_RELEASE_DATE "2013-10-18"
+#define RUBY_PATCHLEVEL 336
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 10
-#define RUBY_RELEASE_DAY 11
+#define RUBY_RELEASE_DAY 18
 
 #include "ruby/version.h"
 
Index: ruby_2_0_0/test/ruby/test_file_exhaustive.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_file_exhaustive.rb	(revision 43343)
+++ ruby_2_0_0/test/ruby/test_file_exhaustive.rb	(revision 43344)
@@ -519,6 +519,33 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_file_exhaustive.rb#L519
     ENV["HOME"] = home
   end
 
+  if /mswin|mingw/ =~ RUBY_PLATFORM
+    def test_expand_path_home_memory_leak_in_path
+      assert_no_memory_leak_at_expand_path_home('', 'in path')
+    end
+
+    def test_expand_path_home_memory_leak_in_base
+      assert_no_memory_leak_at_expand_path_home('".",', 'in base')
+    end
+
+    def assert_no_memory_leak_at_expand_path_home(arg, message)
+      prep = 'ENV["HOME"] = "foo"*100'
+      assert_no_memory_leak([], prep, <<-TRY, "memory leaked at non-absolute home #{message}")
+      10000.times do
+        begin
+          File.expand_path(#{arg}"~/a")
+        rescue ArgumentError => e
+          next
+        ensure
+          abort("ArgumentError (non-absolute home) expected") unless e
+        end
+      end
+      GC.start
+      TRY
+    end
+  end
+
+
   def test_expand_path_remove_trailing_alternative_data
     assert_equal File.join(@rootdir, "aaa"), File.expand_path("#{@rootdir}/aaa::$DATA")
     assert_equal File.join(@rootdir, "aa:a"), File.expand_path("#{@rootdir}/aa:a:$DATA")

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r43328


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

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