summaryrefslogtreecommitdiff
path: root/ext/openssl
diff options
context:
space:
mode:
authoremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-22 00:13:07 +0000
committeremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-22 00:13:07 +0000
commit84e835fe4a68586fcb17adc2a6140c737c83dd62 (patch)
tree5c2011f59a8efdfc6a82ae5402b17c6176e8dccd /ext/openssl
parent480c0f69bd7aa81eda0f5b269427442a8a45f6b3 (diff)
* 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
Diffstat (limited to 'ext/openssl')
-rw-r--r--ext/openssl/ossl_engine.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c
index 111e418f91e..79f51b8cdb6 100644
--- a/ext/openssl/ossl_engine.c
+++ b/ext/openssl/ossl_engine.c
@@ -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);
}