ruby-changes:46761
From: normal <ko1@a...>
Date: Thu, 25 May 2017 06:26:30 +0900 (JST)
Subject: [ruby-changes:46761] normal:r58876 (trunk): string.c: fix String#crypt leak introduced in r58866
normal 2017-05-25 06:26:14 +0900 (Thu, 25 May 2017) New Revision: 58876 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58876 Log: string.c: fix String#crypt leak introduced in r58866 * string.c (rb_str_crypt): define LARGE_CRYPT_DATA when allocating Modified files: trunk/string.c trunk/test/ruby/test_string.rb Index: string.c =================================================================== --- string.c (revision 58875) +++ string.c (revision 58876) @@ -8727,7 +8727,7 @@ rb_str_crypt(VALUE str, VALUE salt) https://github.com/ruby/ruby/blob/trunk/string.c#L8727 # if defined SIZEOF_CRYPT_DATA && SIZEOF_CRYPT_DATA <= 256 struct crypt_data cdata, *const data = &cdata; # else -# undef LARGE_CRYPT_DATA +# define LARGE_CRYPT_DATA struct crypt_data *data = ALLOC(struct crypt_data); # endif #else Index: test/ruby/test_string.rb =================================================================== --- test/ruby/test_string.rb (revision 58875) +++ test/ruby/test_string.rb (revision 58876) @@ -546,6 +546,10 @@ CODE https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L546 assert_raise(ArgumentError) {S("mypassword").crypt(S("aa".encode(enc)))} assert_raise(ArgumentError) {S("mypassword".encode(enc)).crypt(S("aa"))} end + + @cls == String and assert_no_memory_leak([], 's = ""', <<~'end;') # do + 1000.times { s.crypt(-"..").clear } + end; end def test_delete -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/