* 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]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
emboss 2011-07-22 00:13:07 +00:00
Родитель 480c0f69bd
Коммит 84e835fe4a
3 изменённых файлов: 27 добавлений и 1 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Fri Jul 22 09:09:43 2011 Martin Bosslet <Martin.Bosslet@googlemail.com>
* 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:37:13 2011 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* lib/csv.rb: Do not modify CSV.generate's argument [ruby-core:38356]

Просмотреть файл

@ -115,7 +115,11 @@ ossl_engine_s_engines(VALUE klass)
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);
}

Просмотреть файл

@ -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