summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_pkey_dh.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 05:55:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-29 05:55:02 +0000
commit451fe269e5ab1270a53ac7bdeceabe47fd431f95 (patch)
treeed014c958a0f622db02af64186def2c70e4c00ba /ext/openssl/ossl_pkey_dh.c
parent5924f9a684ace630d3658a0d6e52270e3686ca9f (diff)
openssl: wrapper object before alloc
* ext/openssl: make wrapper objects before allocating structs to get rid of potential memory leaks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_pkey_dh.c')
-rw-r--r--ext/openssl/ossl_pkey_dh.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c
index 9a58bdf4..234cdaa 100644
--- a/ext/openssl/ossl_pkey_dh.c
+++ b/ext/openssl/ossl_pkey_dh.c
@@ -46,6 +46,7 @@ dh_instance(VALUE klass, DH *dh)
if (!dh) {
return Qfalse;
}
+ obj = NewPKey(klass);
if (!(pkey = EVP_PKEY_new())) {
return Qfalse;
}
@@ -53,7 +54,7 @@ dh_instance(VALUE klass, DH *dh)
EVP_PKEY_free(pkey);
return Qfalse;
}
- WrapPKey(klass, obj, pkey);
+ SetPKey(obj, pkey);
return obj;
}
@@ -66,10 +67,11 @@ ossl_dh_new(EVP_PKEY *pkey)
if (!pkey) {
obj = dh_instance(cDH, DH_new());
} else {
+ obj = NewPKey(cDH);
if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DH) {
ossl_raise(rb_eTypeError, "Not a DH key!");
}
- WrapPKey(cDH, obj, pkey);
+ SetPKey(obj, pkey);
}
if (obj == Qfalse) {
ossl_raise(eDHError, NULL);