ruby-changes:20557
From: emboss <ko1@a...>
Date: Fri, 22 Jul 2011 09:19:43 +0900 (JST)
Subject: [ruby-changes:20557] emboss:r32605 (ruby_1_9_3): * backport r32604 from trunk.
emboss 2011-07-22 09:19:32 +0900 (Fri, 22 Jul 2011) New Revision: 32605 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32605 Log: * backport r32604 from trunk. * ext/openssl/ossl_engine.c: Avoid double free of ENGINE reference. * test/openssl/test_engine.rb: Add a test for it. Thanks to Ippei Obayashi for providing the patch. [ Ruby 1.9 - Bug #5062 ] [ruby-dev:44173] Added files: branches/ruby_1_9_3/test/openssl/test_engine.rb Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/ext/openssl/ossl_engine.c Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 32604) +++ ruby_1_9_3/ChangeLog (revision 32605) @@ -1,3 +1,12 @@ +Fri Jul 22 09:17:43 2011 Martin Bosslet <Martin.Bosslet@g...> + + * backport r32604 from trunk. + + * ext/openssl/ossl_engine.c: Avoid double free of ENGINE reference. + * test/openssl/test_engine.rb: Add a test for it. + Thanks to Ippei Obayashi for providing the patch. + [ Ruby 1.9 - Bug #5062 ] [ruby-dev:44173] + Fri Jul 22 06:39:34 2011 Marc-Andre Lafortune <ruby-core@m...> * lib/csv.rb: Do not modify CSV.generate's argument [ruby-core:38356] Index: ruby_1_9_3/ext/openssl/ossl_engine.c =================================================================== --- ruby_1_9_3/ext/openssl/ossl_engine.c (revision 32604) +++ ruby_1_9_3/ext/openssl/ossl_engine.c (revision 32605) @@ -115,7 +115,11 @@ ary = rb_ary_new(); for(e = ENGINE_get_first(); e; e = ENGINE_get_next(e)){ - WrapEngine(klass, obj, e); + /* Need a ref count of two here because of ENGINE_free being + * called internally by OpenSSL when moving to the next ENGINE + * and by us when releasing the ENGINE reference */ + ENGINE_up_ref(e); + WrapEngine(klass, obj, e); rb_ary_push(ary, obj); } Index: ruby_1_9_3/test/openssl/test_engine.rb =================================================================== --- ruby_1_9_3/test/openssl/test_engine.rb (revision 0) +++ ruby_1_9_3/test/openssl/test_engine.rb (revision 32605) @@ -0,0 +1,15 @@ +require_relative 'utils' + +if defined?(OpenSSL) + +class OpenSSL::TestEngine < Test::Unit::TestCase + + def test_engines_free # [ruby-dev:44173] + OpenSSL::Engine.load + OpenSSL::Engine.engines + OpenSSL::Engine.engines + end + +end + +end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/